在命令行里执行如下命令:
git clone https://github.com/standino/emacs.d.git ~/.emacs.d emacs -nw --batch -l ~/.emacs.d/init.el -f package-refresh-contents
功能 | 键盘操作 |
左移 | h |
右移 | l |
上移 | k |
下移 | j |
光标移到句尾 | ) |
光标移动导句首 | ( |
启用插入模式 | i |
推出插入模式 | Esc |
开始拷贝 | v + y + p |
最后一行 | G |
第一行 | gg |
块操作删除粘贴 | C-v + hlkj + d + p |
块插入 | C-v + kj + I + Esc |
把当前文件加入到org file list | ,mx org-agenda-file-to-front |
使用artist mode 生成图片 | ,mx artist-mode;鼠标中键弹出菜单画图; C-cc退出artist-mode; C-cc生成预览 |
* 如何使用emacs |------+-------------+-------------------------------------+-------------------------------------------------------------------------------------------------------| | 分类 | 快捷键 | 命令 | 说明 | |------+-------------+-------------------------------------+-------------------------------------------------------------------------------------------------------| | 编程 | M-./ C-Mg | | 获得Java变量和方法的引用或声明 | | | | swoop-multi | 在打开的 buffer 查找某个关键字 | | | C-cpg | | 在项目中查找字段 | | | C-ci或S-M t | helm-imenu | 查看当前文件的结构 | | | C-cf或C-cpf | | 打开文件 | | | M-; | | 注释代码 | | | | cleanup-buffer | 格式化文档 | | GTD | C-caa或F12 | | 打开TODO视图 | | | C-cao | | 打开任务总结视图.获得本周/本月/本年任务的列表。公司要求每周要发周报回报上周做了什么,下周准备做什么。 | | | | org-agenda-file-to-front | 把当前org文件加入到GTD统计列表里面。 | | 写作 | C-c C-e R R | | 导出演示文稿 | | | | org-confluence-export-as-confluence | 以conflunce wiki的格式导出文稿 | | | | org-toggle-inline-images | 在 org-mode 中,提供了一個 org-toggle-inline-images 的命令,可以將你插入的圖片顯示出來 | ** 书签操作: | C-x r m Bookmark | bookmark-set | 设置一个名为 Bookmark 的书签。 | | C-x r l | bookmarks-bmenu-list | 列出所有已保存的书签。 | | | bookmark-delete | 删除一个书签。 | | C-x r b Bookmark | bookmark-jump | 跳转至名为 Bookmark 的书签中所设置的位置。 | | | bookmark-save | 将所有的书签保存到书签文件 ~/.emac.bmk 中。 | * 如何配置emacs 引入所需插件 (require 'wc)
(defalias 'tt 'toggle-truncate-lines)
(defalias 'yas 'yas/expand)
(defalias 'sql-org-table 'org-table-create-or-convert-from-region)
(defalias 'sql-org-next 'orgtbl-tab)
;;(global-set-key "\C-z" 'set-mark-command)
(global-set-key (kbd "C-c t") 'org-table-create-or-convert-from-region)
(global-set-key (kbd "C-c n") 'orgtbl-tab)
(global-set-key "\C-o" 'scroll-down)
(global-set-key [(f3)] 'dired)
(global-set-key [(f4)] 'eshell)
(global-set-key [(f8)] 'highlight-symbol-at-point)
(global-set-key (kbd "<f9>") 'list-bookmarks)
(global-set-key [(f10)] 'bookmark-set)
(require-package 'evil-org) (require 'evil-org)
(require-package 'org-toc) (eval-after-load "org-toc-autoloads" '(progn (if (require 'org-toc nil t) (add-hook 'org-mode-hook 'org-toc-enable) (warn "org-toc not found"))))
;; 格式化org clock 输出
(setq org-pretty-entities t)
(setq org-agenda-files (list
;; "~/cwboot/work/"
"~/cwboot/blog/planning2015.org"
"~/.emacs.d/emacs-init.org"
"~/cwboot/work/Personal.org"
"~/cwboot/work/jd.org"
))
(setq org-agenda-custom-commands
'(("a" "My custom agenda"
(
(sacha/org-agenda-clock)
(todo "OKTODAY" )
(todo "STARTED")
(org-agenda-list nil nil 1)
;; (sacha/org-agenda-load)
(todo "WAITING")
(todo "DELEGATED" )
(todo "TODO")
;; (tags "PROJECT")
;; (tags "PROJECT-WAITING")
(todo "MAYBE")
)
)
("d" "delegated"
((todo "DELEGATED" ))
)
("c" "finished tasks"
((todo "DONE" )
(todo "DEFERRED" )
(todo "CANCELLED" )
)
)
("w" "waiting"
((todo "WAITING" ))
)
("o" "overview"
((todo "WAITING" )
(cw/org-agenda-clock-daily-report)
(cw/org-agenda-clock-thisweek)
(cw/org-agenda-clock-thismonth)
(cw/org-agenda-clock-lastQ)
(cw/org-agenda-clock-thisyear)
)
)
("x" "Weekly schedule" agenda ""
((org-agenda-ndays 7) ;; agenda will start in week view
(org-agenda-repeating-timestamp-show-all nil) ;; ensures that repeating events appear on all relevant dates
(org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled))))
("A" "priority A"
((tags "//#A" ))
)
("T" todo-tree "TODO")
("W" todo-tree "WAITING")
("u" "Unscheduled" ((sacha/org-agenda-list-unscheduled)))
("v" tags-todo "+BOSS-URGENT")
("U" tags-tree "+BOSS-URGENT")
("f" occur-tree "\\<FIXME\\>")
)
)
GTD 提醒
(defun sacha/org-clock-in-if-starting ()
"Clock in when the task is marked STARTED."
(when (string= org-state "STARTED")
(org-clock-in)
))
(add-hook 'org-after-todo-state-change-hook
'sacha/org-clock-in-if-starting)
(defadvice org-clock-in (after sacha activate)
"Set this task's status to 'STARTED'."
(org-todo "STARTED"))
(defun sacha/org-clock-out-if-waiting ()
"Clock in when the task is marked STARTED."
(when (string= org-state "WAITING")
(org-clock-out)))
(add-hook 'org-after-todo-state-change-hook
'sacha/org-clock-out-if-waiting)
(defun sacha/org-clock-out-if-oktoday ()
"clock out when the task is marked OKTODAY."
(when (string= org-state "OKTODAY")
(org-clock-out)))
(add-hook 'org-after-todo-state-change-hook
'sacha/org-clock-out-if-oktoday)
(setq org-agenda-span 'day)
;; I use C-c c to start capture mode
(global-set-key (kbd "C-c c") 'org-capture)
(define-key global-map "\C-cr"
(lambda () (interactive) (org-capture nil "m")))
(define-key global-map "\C-cd"
(lambda () (interactive) (org-capture nil "d")))
(global-set-key (kbd "<f12>") (lambda () (interactive)(switch-to-buffer "*Org Agenda*")(org-agenda-redo)))
;;http://doc.norang.ca/org-mode.html
;;18.38 Remove Multiple State Change Log Details From The Agenda
;;I skip multiple timestamps for the same entry in the agenda view with the following setting.
(setq org-agenda-skip-additional-timestamps-same-entry t)
(setq org-crypt-disable-auto-save nil)
(require 'org-crypt)
; Encrypt all entries before saving
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
; GPG key to use for encryption
(setq org-crypt-key "F0B66B40")
;;Enable Auto Fill mode
(defun my-org-mode-hook ()
(setq-default fill-column 130)
(auto-fill-mode 1))
(add-hook 'org-mode-hook 'my-org-mode-hook)
(defun org-clocktable-indent-string (level)
(if (= level 1) ""
(let ((str " "))
(dotimes (k (1- level) str)
(setq str (concat "--" str))))))
- State “OKTODAY” from “STARTED” [2014-05-09 五 14:37]
- State “OKTODAY” from “STARTED” [2014-05-07 三 19:12]
- http://orgmode.org/worg/org-tutorials/non-beamer-presentations.html#sec-3
- https://github.com/yjwen/org-reveal/blob/master/Readme.org
- http://forum.ubuntu.org.cn/viewtopic.php?t=810
- http://orgmode.org/manual/Beamer-export.html
- http://orgmode.org/worg/exporters/beamer/ox-beamer.html
- https://github.com/fniessen/refcard-org-beamer
- http://orgmode.org/worg/exporters/beamer/ox-beamer.htmlhttp://orgmode.org/worg/exporters/beamer/ox-beamer.html
sudo apt-get install texlive-fonts-recommended sudo apt-get install texlive cjk-latex latex-cjk-all latex-beamer
(setq org-latex-coding-system 'utf-8)
;;; Export language
(setq org-export-default-language "zh-CN")
(eval-after-load "ox-latex"
;; update the list of LaTeX classes and associated header (encoding, etc.)
;; and structure
'(add-to-list 'org-latex-classes
`("beamer"
,(concat "\\documentclass[presentation]{beamer}\n"
"[DEFAULT-PACKAGES]"
"[PACKAGES]"
"[EXTRA]\n")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
C-c C-e o o (org-odt-export-to-odt)
下载 reveal
git clone https://github.com/hakimel/reveal.js.git mv reveal.js to the org file folder
(require-package 'ox-reveal)
“C-c C-e R R” : 导出html 文件
To wake-up Org-reveal now, type “M-x load-library”, then type “ox-reveal”.
Now you can export this manual into Reveal.js presentation by typing “C-c C-e R R”.
Open the generated “Readme.html” in your browser and enjoy the cool slides.
具体编写出的演示文档,可以参考 这个例子
(require-package 'org)
(require-package 'org-page)
(require 'org-page)
(setq op/site-main-title "简单")
(setq op/site-sub-title "让生活更精彩。")
(setq op/site-domain "http://standino.github.io/")
(setq op/personal-github-link "https://github.com/standino")
(setq op/personal-disqus-shortname "standino")
(setq op/personal-google-analytics-id "UA-46515756-1")
(setq op/repository-org-branch "master") ;; default is "source"
(setq op/repository-html-branch "master") ;; default is "master"
(setq op/repository-directory "~/cwboot/" )
(setq op/category-config-alist
'(("blog" ;; this is the default configuration
:show-meta t
:show-comment t
:uri-generator op/generate-uri
:uri-template "/blog/html/%y/%m/%d/%t/"
:sort-by :date ;; how to sort the posts
:category-index t) ;; generate category index or not
("work"
:show-meta t
:show-comment t
:uri-generator op/generate-uri
:uri-template "/work/%t/"
:sort-by :mod-date
:category-index t)
("index"
:show-meta nil
:show-comment t
:uri-generator op/generate-uri
:uri-template "/"
:sort-by :date
:category-index nil)
("about"
:show-meta nil
:show-comment nil
:uri-generator op/generate-uri
:uri-template "/about/"
:sort-by :date
:category-index nil)))
(defun cw/pub-all ()
(interactive)
(op/do-publication nil "HEAD~1" "~/standino.github.com/" nil)
(op/do-publication nil "HEAD~1" "~/myblog/" nil)
)
(setq org-ditaa-jar-path "~/.emacs.d/lib/ditaa.jar")
(setq org-plantuml-jar-path "~/.emacs.d/lib/plantuml.jar")
(add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
; Make babel results blocks lowercase
(setq org-babel-results-keyword "results")
(defun bh/display-inline-images ()
(condition-case nil
(org-display-inline-images)
(error nil)))
(org-babel-do-load-languages
(quote org-babel-load-languages)
(quote ((emacs-lisp . t)
(dot . t)
(ditaa . t)
(R . t)
(python . t)
(ruby . t)
(gnuplot . t)
(clojure . t)
(sh . t)
(ledger . t)
(org . t)
(plantuml . t)
(latex . t))))
; Do not prompt to confirm evaluation
; This may be dangerous - make sure you understand the consequences
; of setting this -- see the docstring for details
(setq org-confirm-babel-evaluate nil)
; Use fundamental mode when editing plantuml blocks with C-c '
(add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
(setq op/theme-root-directory "~/.emacs.d/themes")
(setq op/theme 'sb-admin-2)
C-c a e
: 导出到~/review/目录下。- =C-c a R : 按天/周/月回顾任务
;; define "R" as the prefix key for reviewing what happened in various
;; time periods
(add-to-list 'org-agenda-custom-commands
'("R" . "Review" )
)
;; Common settings for all reviews
(setq efs/org-agenda-review-settings
'(
(org-agenda-show-all-dates t)
(org-agenda-start-with-log-mode t)
(org-agenda-start-with-clockreport-mode t)
(org-agenda-archives-mode t)
;; I don't care if an entry was archived
(org-agenda-hide-tags-regexp
(concat org-agenda-hide-tags-regexp
"\\|ARCHIVE"))
))
;; Show the agenda with the log turn on, the clock table show and
;; archived entries shown. These commands are all the same exept for
;; the time period.
(add-to-list 'org-agenda-custom-commands
`("Rw" "Week in review"
agenda ""
;; agenda settings
,(append
efs/org-agenda-review-settings
'((org-agenda-span 'week)
(org-agenda-start-on-weekday 0)
(org-agenda-overriding-header "Week in Review"))
)
("~/review/week.html")
))
(add-to-list 'org-agenda-custom-commands
`("Rd" "Day in review"
agenda ""
;; agenda settings
,(append
efs/org-agenda-review-settings
'((org-agenda-span 'day)
(org-agenda-overriding-header "Week in Review"))
)
("~/review/day.html")
))
(add-to-list 'org-agenda-custom-commands
`("Rm" "Month in review"
agenda ""
;; agenda settings
,(append
efs/org-agenda-review-settings
'((org-agenda-span 'month)
(org-agenda-start-day "01")
(org-read-date-prefer-future nil)
(org-agenda-overriding-header "Month in Review"))
)
("~/review/month.html")
))
(add-to-list 'org-modules' org-timer)
(setq org-timer-default-timer 25)
(add-hook 'org-clock-in-hook' (lambda ()
(if (not org-timer-current-timer)
(org-timer-set-timer '(16)))))
(add-hook 'org-clock-out-hook' (lambda ()
(setq org-mode-line-string nil)
))
(add-hook 'org-timer-done-hook 'have-a-rest)
(defun have-a-rest ()
"alert a have a rest msg"
(interactive)
(save-window-excursion
(shell-command(concat "notify-send '休息一下吧'"))
(x-popup-dialog t '( "休息一下吧" ("okay" . t)) t)
)
)
(defvar zendisp "zenity --info --title='Appointment' ")
(defun my-appt-disp-window (min-to-app new-time msg)
(save-window-excursion
(shell-command(concat "notify-send '"
(string-replace-all "<" "[]" msg)
"'"
))
(shell-command (concat zendisp
" --text='"
(string-replace-all "<" "[]" msg)
"'"
))
)
)
;;;; Get appointments for today
(defun my-org-agenda-to-appt ()
(interactive)
(setq appt-time-msg-list nil)
(let ((org-deadline-warning-days 0)) ;; will be automatic in org 5.23
(org-agenda-to-appt)))
;; Run once, activate and schedule refresh
(my-org-agenda-to-appt)
(appt-activate t)
(run-at-time "24:01" nil 'my-org-agenda-to-appt)
(setq appt-issue-message t)
(setq appt-message-warning-time '1)
(setq appt-display-interval '1)
(setq org-deadline-warning-days '1)
; Update appt each time agenda opened.
(add-hook 'org-finalize-agenda-hook 'my-org-agenda-to-appt)
; Setup zenify, we tell appt to use window, and replace default function
(setq appt-display-format 'window)
(setq appt-disp-window-function (function my-appt-disp-window))
(setq org-clock-into-drawer t) (setq org-log-into-drawer t)
;;
;; Resume clocking task when emacs is restarted
(org-clock-persistence-insinuate)
;;
;; Show lot of clocking history so it's easy to pick items off the C-F11 list
(setq org-clock-history-length 23)
;; Resume clocking task on clock-in if the clock is open
(setq org-clock-in-resume t)
;; Separate drawers for clocking and logs
(setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
;; Save clock data and state changes and notes in the LOGBOOK drawer
(setq org-clock-into-drawer t)
;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
(setq org-clock-out-remove-zero-time-clocks t)
;; Clock out when moving task to a done state
(setq org-clock-out-when-done t)
;; Save the running clock and all clock history when exiting Emacs, load it on startup
(setq org-clock-persist t)
;; Do not prompt to resume an active clock
(setq org-clock-persist-query-resume nil)
;; Enable auto clock resolution for finding open clocks
(setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
;; Include current clocking task in clock reports
(setq org-clock-report-include-clocking-task t)
(setq org-log-done (quote time))
(setq org-log-into-drawer t)
(setq org-log-state-notes-insert-after-drawers nil)
(setq org-crypt-disable-auto-save nil)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(require 'ox-confluence)
(defun clocktable-by-tag/shift-cell (n) (let ((str "")) (dotimes (i n) (setq str (concat str "| "))) str)) (defun clocktable-by-tag/insert-tag (params) (let ((tag (plist-get params :tags))) (insert "|--\n") (insert (format "| %s | *Tag time* |\n" tag)) (let ((total 0)) (mapcar (lambda (file) (let ((clock-data (with-current-buffer (find-file-noselect file) (org-clock-get-table-data (buffer-name) params)))) (when (> (nth 1 clock-data) 0) (setq total (+ total (nth 1 clock-data))) (insert (format "| | File *%s* | %.2f |\n" (file-name-nondirectory file) (/ (nth 1 clock-data) 60.0))) (dolist (entry (nth 2 clock-data)) (insert (format "| | . %s%s | %s %.2f |\n" (org-clocktable-indent-string (nth 0 entry)) (nth 1 entry) (clocktable-by-tag/shift-cell (nth 0 entry)) (/ (nth 3 entry) 60.0))))))) (org-agenda-files)) (save-excursion (re-search-backward "*Tag time*") (org-table-next-field) (org-table-blank-field) (insert (format "*%.2f*" (/ total 60.0))))) (org-table-align))) (defun org-dblock-write:clocktable-by-tag (params) (insert "| Tag | Headline | Time (h) |\n") (insert "| | | <r> |\n") (let ((tags (plist-get params :tags))) (mapcar (lambda (tag) (setq params (plist-put params :tags tag)) (clocktable-by-tag/insert-tag params)) tags)))
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer.
Including indent-buffer, which should not be called automatically on save."
(interactive)
(untabify-buffer)
(delete-trailing-whitespace)
(indent-buffer))
(defun untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
;;启动调试信息
;; (setq debug-on-error t)
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . anjsp-mode))
(defun bf-pretty-print-xml-region (begin end)
"Pretty format XML markup in region. You need to have nxml-mode http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do this.
The function inserts linebreaks to separate tags that have nothing but whitespace between them. It then indents the markup by using nxml's indentation rules."
(interactive "r")
(save-excursion (nxml-mode) (goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end))
(message "Ah, much better!"))
(defun msh-close-tag ()
"Close the previously defined XML tag"
(interactive)
(let ((tag nil)
(quote nil))
(save-excursion
(do ((skip 1))
((= 0 skip))
(re-search-backward "</?[a-zA-Z0-9_-]+")
(cond ((looking-at "</")
(setq skip (+ skip 1)))
((not (looking-at "<[a-zA-Z0-9_-]+[^>]*?/>"))
(setq skip (- skip 1)))))
(when (looking-at "<\\([a-zA-Z0-9_-]+\\)")
(setq tag (match-string 1)))
(if (eq (get-text-property (point) 'face)
'font-lock-string-face)
(setq quote t)))
(when tag
(setq quote (and quote
(not (eq (get-text-property (- (point) 1) 'face)
'font-lock-string-face))))
(if quote
(insert "\""))
(insert "</" tag ">")
(if quote
(insert "\"")))))
(setq my-idea-home "~/ideas/")
(setq my-emacs-home "~/ideas/emacs/")
(add-to-list 'load-path (concat my-emacs-home "lib"))
(require 'wc)
(defun cw-win-open-host-file () (interactive) (find-file (concat "/cygdrive/c/Windows/System32/drivers/etc/" "hosts")) ) (require 'require-or-install) (defun my-require-or-install (feature) (require-or-install feature (format "%s.el" feature) ) ) (defun my-require (feature) " put the ~/.emacs.d/$feature to path" (add-to-list 'load-path (format "~/.emacs.d/%s" feature) ) (my-require-or-install feature) )
(defun set-clipboard-contents-from-string (str)
"Copy the value of string STR into the clipboard."
(let ((x-select-enable-clipboard t))
(x-select-text str)))
(defun string-replace-all (old new big)
"Replace all occurences of OLD string with NEW string in BIG sting."
(do ((newlen (length new))
(i (search old big)
(search old big :start2 (+ i newlen))))
((null i) big)
(setq big
(concatenate 'string
(subseq big 0 i)
new
(subseq big (+ i (length old))))))
)
(defun path-to-clipboard ()
"Copy the current file's path to the clipboard.
If the current buffer has no file, copy the buffer's default directory."
(interactive)
(let (
(path (expand-file-name (or (buffer-file-name) default-directory)))
)
(set-clipboard-contents-from-string path )
(kill-new path)
(message "%s" path)))
(defun win-path()
(concat "C:\\dsw" (string-replace-all "/" "\\" (expand-file-name (or (buffer-file-name) default-directory))))
)
(defun buffer-dir()
(file-name-directory (expand-file-name (or (buffer-file-name) default-directory)))
)
(defun kill-unmodified-buffers ()
"Kill some buffers. Asks the user whether to kill each one of them.
Non-interactively, if optional argument LIST is non-nil, it
specifies the list of buffers to kill, asking for approval for each one."
(interactive)
(setq list (buffer-list))
(while list
(let* ((buffer (car list))
(name (buffer-name buffer)))
(and name ; Can be nil for an indirect buffer
; if we killed the base buffer.
(not (string-equal name ""))
(/= (aref name 0) ?\s)
(if (buffer-modified-p buffer)
(message "")(kill-buffer buffer))
))
(setq list (cdr list))))
(setq grep-files-aliases
(quote (("asm" . "*.[sS]")
("c" . "*.c") ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++")
("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++")
("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++")
("ch" . "*.[ch]")
("el" . "*.el")
("h" . "*.h")
("l" . "[Cc]hange[Ll]og*")
("m" . "[Mm]akefile*")
("tex" . "*.tex")
("texi" . "*.texi")
(java . "*.java")
(sql . "*.sql *.SQL")
(xml . "*.xml"))))
;;设置备份策略
(setq make-backup-files t) ;;启用备份功能
(setq vc-make-backup-files t) ;;使用版本控制系统的时候也启用备份功能
(setq version-control t) ;;启用版本控制,即可以备份多次
(setq kept-old-versions 2) ;;备份最原始的版本两次,即第一次编辑前的文档,和第二次编
;;辑前的文档
(setq kept-new-versions 6) ;;备份最新的版本6次,理解同上
(setq delete-old-versions t) ;;删掉不属于以上3种版本的版本
(setq backup-directory-alist '(("." . "~/backup/emacs/backup")));;设置备份文件的路径到~/backup/emacs/backup中
(setq backup-by-copying t) ;;备份设置方法,直接拷贝
(setq backup-enable-predicate 'ecm-backup-enable-predicate);;设置备份条件
;;关闭匹配下列目录或文件的备份功能
(defun ecm-backup-enable-predicate (filename)
(and (not (string= "/tmp/" (substring filename 0 5)))
(not (string-match "semanticdb" filename))
))
;;关闭自动保存模式
;(setq auto-save-mode nil)
;;不生成 #filename# 临时文件
(setq auto-save-default nil)
;;自动的在文件末增加一新行
(setq require-final-newline t)
;;当光标在行尾上下移动的时候,始终保持在行尾。
(setq track-eol t)
(require-package 'dic-lookup-w3m) (require 'dic-lookup-w3m) (require 'dic-lookup-w3m-zh)
- C-x 0 : 关闭窗口,不是关闭buffer。
- M-1: 选择第一个窗口。
;; http://tapoueh.org/emacs/switch-window.html
(require 'switch-window)
;; move window
(require-package 'window-numbering)
(custom-set-faces '(window-numbering-face ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold)))))
(window-numbering-mode 1)
;; buffer-move.el
(global-set-key (kbd "C-c C-b C-k") 'buf-move-up)
(global-set-key (kbd "C-c C-b C-j") 'buf-move-down)
(global-set-key (kbd "C-c C-b C-h") 'buf-move-left)
(global-set-key (kbd "C-c C-b C-l") 'buf-move-right)
- https://github.com/fxbois/web-mode
- https://github.com/fgallina/multi-web-mode
- http://web-mode.org/
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.vm\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-hook 'web-mode-hook
'(lambda()
(setq tab-width 4)
(setq indent-tabs-mode nil)
(setq c-basic-offset 4)
))
- C-c k : 模板插入。使用yasnippet定义的模板,输入模板简称,然后使用该快捷键插入预定义的模板。
(dolist (mode '(magit-log-edit-mode
log-edit-mode org-mode text-mode haml-mode
git-commit-mode
sass-mode yaml-mode csv-mode espresso-mode haskell-mode
html-mode nxml-mode sh-mode smarty-mode clojure-mode
lisp-mode java-mode textile-mode markdown-mode tuareg-mode
js3-mode css-mode less-css-mode sql-mode web-mode
sql-interactive-mode org-mode
inferior-emacs-lisp-mode))
;; (add-to-list 'ac-modes mode)
)
(require-package 'dropdown-list)
(require-package 'yasnippet)
(require 'init-yasnippet)
;;(require-package 'go-snippets)
;;(require-package 'java-snippets)
;;(require-package 'yasnippet-bundle)
use keyfreq-show to see how many times you used a command.
(require-package 'keyfreq) (keyfreq-mode 1) (keyfreq-autosave-mode 1)
`M-x evilnc-default-hotkeys` assigns hotkey `M-;` to `evilnc-comment-or-uncomment-lines` `M-x evilnc-comment-or-uncomment-lines` comment or uncomment lines. `M-x evilnc-comment-or-uncomment-to-the-line` will comment/uncomment from current line to the specified line number. The line number is passed as parameter of the command. For example, `C-u 99 evilnc-comment-or-uncomment-to-the-line` will comment code from current line to line 99.
(require-package 'evil-nerd-commenter)
- State “DONE” from “WAITING” [2014-12-26 Fri 08:49]
- State “WAITING” from “STARTED” [2014-12-22 Mon 13:28]
配置从这个 页面拷贝的。
(require-package 'go-mode) ;; golang mode ;;(require 'go-mode-load) (require-package 'go-autocomplete) ;; speedbar ;;(speedbar 1) ;;(speedbar-add-supported-extension ".go") (add-hook 'go-mode-hook '(lambda () ;; gocode (auto-complete-mode 1) (setq ac-sources '(ac-source-go)) ;; Imenu & Speedbar (setq imenu-generic-expression '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1) ("func" "^func *\\(.*\\) {" 1))) (imenu-add-to-menubar "Index") ;; Outline mode (make-local-variable 'outline-regexp) (setq outline-regexp "//\\.\\|//[^\r\n\f][^\r\n\f]\\|pack\\|func\\|impo\\|cons\\|var.\\|type\\|\t\t*....") (outline-minor-mode 1) (local-set-key "\M-a" 'outline-previous-visible-heading) (local-set-key "\M-e" 'outline-next-visible-heading) ;; Menu bar (require 'easymenu) (defconst go-hooked-menu '("Go tools" ["Go run buffer" go t] ["Go reformat buffer" go-fmt-buffer t] ["Go check buffer" go-fix-buffer t])) (easy-menu-define go-added-menu (current-local-map) "Go tools" go-hooked-menu) ;; Other (setq show-trailing-whitespace t) )) ;; helper function (defun go () "run current buffer" (interactive) (compile (concat "go run " (buffer-file-name)))) ;; helper function (defun go-fmt-buffer () "run gofmt on current buffer" (interactive) (if buffer-read-only (progn (ding) (message "Buffer is read only")) (let ((p (line-number-at-pos)) (filename (buffer-file-name)) (old-max-mini-window-height max-mini-window-height)) (show-all) (if (get-buffer "*Go Reformat Errors*") (progn (delete-windows-on "*Go Reformat Errors*") (kill-buffer "*Go Reformat Errors*"))) (setq max-mini-window-height 1) (if (= 0 (shell-command-on-region (point-min) (point-max) "gofmt" "*Go Reformat Output*" nil "*Go Reformat Errors*" t)) (progn (erase-buffer) (insert-buffer-substring "*Go Reformat Output*") (goto-char (point-min)) (forward-line (1- p))) (with-current-buffer "*Go Reformat Errors*" (progn (goto-char (point-min)) (while (re-search-forward "<standard input>" nil t) (replace-match filename)) (goto-char (point-min)) (compilation-mode)))) (setq max-mini-window-height old-max-mini-window-height) (delete-windows-on "*Go Reformat Output*") (kill-buffer "*Go Reformat Output*")))) ;; helper function (defun go-fix-buffer () "run gofix on current buffer" (interactive) (show-all) (shell-command-on-region (point-min) (point-max) "go tool fix -diff"))
使用Project新建项目非常简单,在项目根目录新建一个名为”.projectile”空白文件,打开该项目下的任一文件即打开了该项目。
(setq projectile-enable-caching nil)
(require 'sql)
(require 'mysql)
(setq sql-product 'mysql)
(add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.SQL\\'" . sql-mode))
;;保存历史
(add-hook 'sql-interactive-mode-hook
(lambda ()
(setq sql-input-ring-file-name "~/sql_history")
(setq comint-scroll-to-bottom-on-output t)
(setq tab-width 4)
(set (make-local-variable 'truncate-lines) t)
))
;;
(add-hook 'sql-mode-hook
(lambda ()
(setq tab-width 4)
(setq indent-tabs-mode nil)
))
(setq sql-mysql-options '("-C" "-t" "-f" "-n"))
(setq sql-connection-alist
'((pool-sone-dev
(sql-product 'mysql)
(sql-server "192.168.178.50")
(sql-user "sone")
(sql-password "sone")
(sql-database "sone")
(sql-port 3358))
(pool-ras-dev
(sql-product 'mysql)
(sql-server "192.168.229.76")
(sql-user "root")
(sql-password "123456")
(sql-database "JDHR")
(sql-port 3306))
(pool-retail-dev
(sql-product 'mysql)
(sql-server "192.168.206.120")
(sql-user "ipc")
(sql-password "ipc")
(sql-database "retail")
(sql-port 3358))))
(defun sql-connect-preset (name)
"Connect to a predefined SQL connection listed in `sql-connection-alist'"
(eval `(let ,(cdr (assoc name sql-connection-alist))
(flet ((sql-get-login (&rest what)))
(sql-product-interactive sql-product)))))
(defun sql-pool-sone-dev ()
(interactive)
(sql-connect-preset 'pool-sone-dev))
(defun sql-pool-ras-dev ()
(interactive)
(sql-connect-preset 'pool-ras-dev))
(defun sql-pool-retail-dev ()
(interactive)
(sql-connect-preset 'pool-retail-dev))
(setq sql-send-terminator ";")
;;(eval-after-load "sql"
;; '(load-library "sql-indent"))
(defgroup xdb-connect nil
"interactiv db-sessions"
:prefix "xdb-"
:group 'local)
(defcustom xdb-mysql-sqli-file "~/ideas/mysql/mysqlSQL-log.sql"
"Default SQLi file for mysql-sessions"
:type 'string
:group 'xdb-connect)
(setq global-mode-string
(append global-mode-string
'(" " cw-my-sql-str
" "))
)
(defun cw-update-db-name(dbname userName)
(setq cw-my-sql-str (format "DB:%s" dbname))
)
(defun cw-mysql-sone-dev ()
"connect to a mysql server with interactiv sql-Buffer"
(interactive)
(add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.SQL\\'" . sql-mode))
(find-file-other-window xdb-mysql-sqli-file)
(sql-pool-sone-dev)
(other-window -1)
(sql-set-sqli-buffer-generally)
(cw-update-db-name "sone-dev" "")
)
(defun cw-mysql-ras-dev ()
"connect to a mysql server with interactiv sql-Buffer"
(interactive)
(add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.SQL\\'" . sql-mode))
(find-file-other-window xdb-mysql-sqli-file)
(sql-pool-ras-dev)
(other-window -1)
(sql-set-sqli-buffer-generally)
(cw-update-db-name "ras-dev" "")
)
(defun cw-mysql-retail-dev ()
"connect to a mysql server with interactiv sql-Buffer"
(interactive)
(add-to-list 'auto-mode-alist '("\\.sql\\'" . sql-mode))
(add-to-list 'auto-mode-alist '("\\.SQL\\'" . sql-mode))
(find-file-other-window xdb-mysql-sqli-file)
(sql-pool-retail-dev)
(other-window -1)
(sql-set-sqli-buffer-generally)
(cw-update-db-name "retail-dev" "")
)
(setq sml/theme 'respectful) (require-package 'smart-mode-line) (sml/setup)
光标不闪烁
(blink-cursor-mode -1)
高亮当前行
(global-hl-line-mode)
(setq url-proxy-services '(("no_proxy" . "^\\(localhost\\|10.*\\|*.__my_company_1__.com\\|*.360buy.com\\\|orgmode.org\\\|*.gnu.org\\)") ("http" . "127.0.0.1:8087") ("https" . "127.0.0.1:8087")))
cd git clone https://github.com/cloudera/piglatin-mode.git
(load-file "~/piglatin-mode/piglatin.el")
Lisp commands removing consecutive duplicates
The command ‘M-x uniquify-buffer-lines’ will remove identical adjacent lines in the current buffer, similar to what is obtained with the unix uniq command.
(defun uniquify-region-lines (beg end)
"Remove duplicate adjacent lines in region."
(interactive "*r")
(save-excursion
(goto-char beg)
(while (re-search-forward "^\\(.*\n\\)\\1+" end t)
(replace-match "\\1"))))
(defun uniquify-buffer-lines ()
"Remove duplicate adjacent lines in the current buffer."
(interactive)
(uniquify-region-lines (point-min) (point-max)))
It is important to note that functions which find duplicate lines don’t always sort lines before looking for dups as this may or may not be what one expects or desires of a particular function.
Where the lines of a file are presorted it can be convenient to use something like this:
(defun find-duplicate-lines (&optional insertp interp)
(interactive "i\np")
(let ((max-pon (line-number-at-pos (point-max)))
(gather-dups))
(while (< (line-number-at-pos) max-pon) (= (forward-line) 0)
(let ((this-line (buffer-substring-no-properties (line-beginning-position 1) (line-end-position 1)))
(next-line (buffer-substring-no-properties (line-beginning-position 2) (line-end-position 2))))
(when (equal this-line next-line) (setq gather-dups (cons this-line gather-dups)))))
(if (or insertp interp)
(save-excursion (new-line) (princ gather-dups (current-buffer)))
gather-dups)))
This function, while inefficient (note cons in tail of while form) is quite handy for locating duplicates before removing them, i.e. situations of type: ‘uniquify-maybe’. Extend ‘find-duplicate-lines’ by comparing its result list with one or more of the list comparison procedures ‘set-difference’, ‘union’, ‘intersection’, etc. from the CL package (require ‘cl).
(defun djcb-duplicate-line (&optional commentfirst)
"comment line at point; if COMMENTFIRST is non-nil, comment the original"
(interactive)
(beginning-of-line)
(push-mark)
(end-of-line)
(let ((str (buffer-substring (region-beginning) (region-end))))
(when commentfirst
(comment-region (region-beginning) (region-end)))
(insert-string
(concat (if (= 0 (forward-line 1)) "" "\n") str "\n"))
(forward-line -1)))
;; or choose some better bindings....
;; duplicate a line
(global-set-key (kbd "C-c y") 'djcb-duplicate-line)
;; duplicate a line and comment the first
(global-set-key (kbd "C-c c") (lambda()(interactive)(djcb-duplicate-line t)))
;; 当backspace用
(keyboard-translate ?\C-h ?\C-?)
(defun cygwin-or-linux (cyg ln) "cyg is the function for cygwin, ln is the function for linux." (interactive) (if (equal system-type 'cygwin) (if cyg (funcall cyg)) ) (if (equal system-type 'windows-nt) (if cyg (funcall cyg)) ) (if (equal system-type 'gnu/linux) (if ln (funcall ln)) ) ) (defun cygwin-do (fn) " only run for cygwin" (interactive) (if (equal system-type 'cygwin) (if fn (funcall fn)) ) ) (defun win-do (fn) " only run for win" (interactive) (if (equal system-type 'windows-nt) (if fn (funcall fn)) ) ) (defun linux-do (fn) " only run for linux" (interactive) (if (equal system-type 'gnu/linux) (if fn (funcall fn)) ) ) ;;上下分屏 ;;(setq split-width-threshold most-positive-fixnum)
(defun sacha/org-agenda-clock (match)
;; Find out when today is
(let* ((inhibit-read-only t))
(goto-char (point-max))
(org-dblock-write:clocktable
`(:scope agenda
:maxlevel 8
:block today
:formula %
:compact t
:fileskip0
:narrow 150!
))))
(defun cw/org-agenda-clock (match)
;; Find out when today is
(let* ((inhibit-read-only t))
(goto-char (point-max))
(org-dblock-write:clocktable
`(:scope agenda
:maxlevel 8
:block today
:compact t
:fileskip0
:narrow 150!
))))
(defun cw/tasks-last-week ()
"Produces an org agenda tags view list of all the tasks completed
last week."
(interactive)
(org-tags-view nil
(concat
(format-time-string "+CLOSED>=\"[%Y-%m-%d]\"" (time-subtract (current-time)
(seconds-to-time (* 7 24 60 60))))
(format-time-string "+CLOSED<=\"[%Y-%m-%d]\"" (current-time)))))
(defun cw/tasks-last-month ()
"Produces an org agenda tags view list of all the tasks completed
last month with the Category Foo."
(interactive)
(org-tags-view nil
(concat
(format-time-string "+CLOSED>=\"[%Y-%m-%d]\"" (time-subtract (current-time)
(seconds-to-time (* 30 24 60 60))))
(format-time-string "+CLOSED<=\"[%Y-%m-%d]\"" (current-time)))))
(defun cw/tasks-last-year ()
"Produces an org agenda tags view list of all the tasks completed
last month with the Category Foo."
(interactive)
(org-tags-view nil
(concat
(format-time-string "+CLOSED>=\"[%Y-%m-%d]\"" (time-subtract (current-time)
(seconds-to-time (* 365 24 60 60))))
(format-time-string "+CLOSED<=\"[%Y-%m-%d]\"" (current-time)))))
(defun clocktable-by-tag/insert-tag (params)
(insert "\n")
(let ((total 0))
(mapcar
(lambda (file)
(let ((clock-data (with-current-buffer (find-file-noselect file)
(org-clock-get-table-data (buffer-name) params))))
(when (> (nth 1 clock-data) 0)
(setq total (+ total (nth 1 clock-data)))
(dolist (entry (nth 2 clock-data))
(insert (format " %s%s\n"
(org-clocktable-indent-string (nth 0 entry))
(nth 1 entry)
))))))
(org-agenda-files))
)
)
(defun cw-org-agenda-clock-by-tag (match)
(let* ((inhibit-read-only t))
(goto-char (point-max))
(clocktable-by-tag/insert-tag
`(:scope agenda
:block today
))))
(defun cw/org-agenda-clock-daily-report (match)
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\n今天完成的工作:\n")
(clocktable-by-tag/insert-tag
`(:scope agenda
:block today
:maxlevel 8
)
)
)
)
(defun cw/org-agenda-clock-thisweek (match)
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\n这周完成的工作:\n")
(clocktable-by-tag/insert-tag
`(:scope agenda
:block thisweek
:maxlevel 8
)
)
)
)
(defun cw/org-agenda-clock-lastweek (match)
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\n上周完成的工作:\n")
(clocktable-by-tag/insert-tag
`(:scope agenda
:block lastweek
)
)
)
)
(defun cw/org-agenda-clock-thismonth (match)
;; Find out when today is
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\nTasks done in this month:\n")
(org-dblock-write:clocktable
`(:scope agenda
:maxlevel 8
:block thismonth
:formula %
:compact t
:fileskip0
:narrow 150!
;; :link t
))))
(defun cw/org-agenda-clock-lastQ (match)
;; Find out when today is
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\n上季度Q完成的工作:\n")
(org-dblock-write:clocktable
`(:scope agenda
:maxlevel 8
;; :block 2014-Q2
:tstart "<-3m>"
:tend "<now>"
:formula %
:compact t
:narrow 150!
;; :link t
))))
(defun cw/org-agenda-clock-thisyear (match)
;; Find out when today is
(let* ((inhibit-read-only t))
(goto-char (point-max))
(insert "\n\nTasks done in this year:\n")
(org-dblock-write:clocktable
`(:scope agenda
:maxlevel 8
:block thisyear
:formula %
:compact t
:narrow 150!
;; :link t
))))
- State “DONE” from “STARTED” [2014-06-03 二 10:47]
- http://docs.huihoo.com/homepage/shredderyin/mutt_frame.html
- http://heim.ifi.uio.no/~jani/mutt/muttemacs.html
- http://emacs-fu.blogspot.com/2009/01/e-mail-with-emacs-using-mutt.html
- http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
- http://wenshanren.org/?p=111
mu4e
sudo apt-get install libgmime-2.6-dev libxapian-dev gnutls-bin sudo apt-get install guile-2.0-dev html2text xdg-utils git clone https://github.com/djcb/mu.git
emacs-conf.sample :
;; standard org <-> remember stuff, RTFM (require 'org-capture) (require 'org-protocol) (setq org-default-notes-file "~/org/gtd.org") (setq org-capture-templates (quote (("m" "Mail" entry (file+headline "~/org/gtd.org" "Incoming") "* TODO %^{Title}\n\n Source: %u, %c\n\n %i" :empty-lines 1) ;; ... more templates here ... ))) ;; ensure that emacsclient will show just the note to be edited when invoked ;; from Mutt, and that it will shut down emacsclient once finished; ;; fallback to legacy behavior when not invoked via org-protocol. (add-hook 'org-capture-mode-hook 'delete-other-windows) (setq my-org-protocol-flag nil) (defadvice org-capture-finalize (after delete-frame-at-end activate) "Delete frame at remember finalization" (progn (if my-org-protocol-flag (delete-frame)) (setq my-org-protocol-flag nil))) (defadvice org-capture-kill (after delete-frame-at-end activate) "Delete frame at remember abort" (progn (if my-org-protocol-flag (delete-frame)) (setq my-org-protocol-flag nil))) (defadvice org-protocol-capture (before set-org-protocol-flag activate) (setq my-org-protocol-flag t)) (defun open-mail-in-mutt (message) "Open a mail message in Mutt, using an external terminal. Message can be specified either by a path pointing inside a Maildir, or by Message-ID." (interactive "MPath or Message-ID: ") (shell-command (format "gnome-terminal -e \"%s %s\"" (substitute-in-file-name "$HOME/bin/mutt-open") message))) ;; add support for "mutt:ID" links (org-add-link-type "mutt" 'open-mail-in-mutt)
mutt-conf.sample:
macro index \eR "|~/bin/remember-mail\n"
mutt-open
;; Capture templates for: TODO tasks, Notes, appointments, phone calls, meetings, and org-protocol (setq org-capture-templates (quote (("t" "todo" entry (file (concat my-idea-home "org/mygtd.org")) "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t) ("r" "respond" entry (file (concat my-idea-home "org/mygtd.org")) "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t) ("n" "note" entry (file (concat my-idea-home "org/mygtd.org")) "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t) ("j" "Journal" entry (file+datetree "~/git/org/diary.org") "* %?\n%U\n" :clock-in t :clock-resume t) ("w" "org-protocol" entry (file (concat my-idea-home "org/mygtd.org")) "* TODO Review %c\n%U\n" :immediate-finish t) ("m" "Meeting" entry (file+headline (concat my-idea-home "org/mygtd.org") "Meeting") "* [#A] [/] %? SCHEDULED:%t :MEETING:\n%U" ) ("p" "Phone call" entry (file (concat my-idea-home "org/mygtd.org")) "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t) ("d" "Development" entry (file+headline (concat my-idea-home "org/mygtd.org") "Development") "* TODO [#A] [/] %? %u SCHEDULED:%t:OFFICE:\n" ) ("h" "Habit" entry (file (concat my-idea-home "org/mygtd.org")) "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d %a .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n"))))
(setq my-idea-home "~/ideas/") (setq my-emacs-home "~/ideas/emacs/") (add-to-list 'load-path (concat my-emacs-home "lib")) (defun cw/open-host-file () (interactive) (find-file (concat "/cygdrive/c/Windows/System32/drivers/etc/" "hosts")) ) (require 'require-or-install) (defun my-require-or-install (feature) (require-or-install feature (format "%s.el" feature) ) ) (defun my-require (feature) " put the ~/.emacs.d/$feature to path" (add-to-list 'load-path (format "~/.emacs.d/%s" feature) ) (my-require-or-install feature) )
wget -c http://jaist.dl.sourceforge.net/project/eclim/eclim/2.3.4/eclim_2.3.4.jar? -O eclim_2.3.4.jar java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8087 -jar eclim_2.3.4.jar ## .eclimrc [email protected]/JD/projects # increase heap size -Xmx256M # increase perm gen size -XX:PermSize=64m -XX:MaxPermSize=128m -XX:-UseCompressedOops
(require 'eclim) (global-eclim-mode) (require 'eclimd) ;;(add-to-list 'auto-mode-alist '("\\.java\\'" . java-mode)) ;;(add-to-list 'auto-mode-alist '("\\.java\\'" . eclim-mode)) (setq eclim-auto-save t eclimd-wait-for-process nil eclim-use-yasnippet t help-at-pt-display-when-idle t help-at-pt-timer-delay 0.1 ) (custom-set-variables '(eclim-eclipse-dirs '("/home/will/JD/tools/springsource/sts-3.4.0.RELEASE")) '(eclimd-default-workspace "/home/will/JD/projects/sone/branches" ) '(eclim-executable "/home/will/JD/tools/springsource/sts-3.4.0.RELEASE/eclim" ) '(eclimd-executable "/home/will/JD/tools/springsource/sts-3.4.0.RELEASE/eclimd" ) ) (help-at-pt-set-timer) (require 'company) (require 'company-emacs-eclim) (company-emacs-eclim-setup) (global-company-mode t) (require 'flymake) (defun my-flymake-init () (list "my-java-flymake-checks" (list (flymake-init-create-temp-buffer-copy 'flymake-create-temp-with-folder-structure)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.java$" my-flymake-init flymake-simple-cleanup)) (defun eclim-run-test () (interactive) (if (not (string= major-mode "java-mode")) (message "Sorry cannot run current buffer.")) (compile (concat eclim-executable " -command java_junit -p " eclim--project-name " -t " (eclim-package-and-class))))
ubuntu 上安装软件
sudo apt-get install texlive-xetex latex-beamer texlive-latex-extra
Emacs 配置
;;; writing presentation ;; {{ export org-mode in Chinese into PDF ;; @see http://freizl.github.io/posts/tech/2012-04-06-export-orgmode-file-in-Chinese.html ;; and you need install texlive-xetex on different platforms ;; To install texlive-xetex: ;; `sudo USE="cjk" emerge texlive-xetex` on Gentoo Linux (setq org-latex-to-pdf-process '("xelatex -interaction nonstopmode -output-directory %o %f" "xelatex -interaction nonstopmode -output-directory %o %f" "xelatex -interaction nonstopmode -output-directory %o %f")) (setq org-latex-pdf-process '("xelatex -interaction nonstopmode -output-directory %o %f" "xelatex -interaction nonstopmode -output-directory %o %f" "xelatex -interaction nonstopmode -output-directory %o %f")) ;; Install a default set-up for Beamer export. (require 'org-install) (require 'org-latex) (require 'ox-beamer) (unless (assoc "beamer-cn" org-latex-classes) (add-to-list 'org-latex-classes '("beamer-cn" "\\documentclass[presentation]{beamer} \\usepackage{xeCJK} \\setCJKmainfont{SimSun} \[DEFAULT-PACKAGES] \[PACKAGES] \[EXTRA]" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) ;; }}
(require 'cc-mode) (define-key c-mode-base-map (kbd "<f2>") 'eclim-problems) (define-key c-mode-base-map "\C-\M-g" 'eclim-java-find-declaration) (define-key c-mode-base-map "\C-\M-o" 'eclim-java-import-organize) (define-key c-mode-base-map "\C-q" 'eclim-java-show-documentation-for-current-element) (define-key c-mode-base-map "\M-i" 'eclim-java-implement) ;; IDEA is C-i (define-key c-mode-base-map (kbd "<M-RET>") 'eclim-problems-correct) (define-key c-mode-base-map (kbd "<M-f7>") 'eclim-java-find-references) (define-key c-mode-base-map (kbd "<S-f6>") 'eclim-java-refactor-rename-symbol-at-point) (define-key c-mode-base-map (kbd "<S-f7>") 'gtags-find-tag-from-here)
all-to-list will not override default elpa, so now you have to repositories, one is elpa, another is myelpa
(require-package 'elpa-mirror) (add-to-list 'package-archives '("mylocalelpa" . "~/myelpa")) (add-to-list 'package-archives '("myelpa" . "https://dl.dropboxusercontent.com/u/858862/myelpa/"))
(add-to-list 'package-archives '("mylocalelpa" . "~/myelpa")) (add-to-list 'package-archives '("myelpa" . "https://dl.dropboxusercontent.com/u/858862/myelpa/"))
● i → Insert 模式,按 ESC 回到 Normal 模式.
● x → 删当前光标所在的一个字符。
● :wq → 存盘 + 退出 (:w 存盘, :q 退出) (陈皓注::w 后可以跟文件名)
● dd → 删除当前行,并把删除的行存到剪贴板里
● p → 粘贴剪贴板
● hjkl (强例推荐使用其移动光标,但不必需) →你也可以使用光标键 (←↓↑→). 注: j 就像下箭头。
● :help <command> → 显示相关命令的帮助。你也可以就输入 :help 而不跟命令。(陈皓注:退出帮助需要输入:q)
你能在vim幸存下来只需要上述的那5个命令,你就可以编辑文本了,你一定要把这些命令练成一种下意识的状态。于是你就可以开始进阶到第二级了。
当是,在你进入第二级时,需要再说一下 Normal 模式。在一般的编辑器下,当你需要copy一段文字的时候,你需要使用 Ctrl 键,比如:Ctrl-C。也就是说,Ctrl键就好像功能键一样,当你按下了功能键Ctrl后,C就不在是C了,而且就是一个命令或是一个快键键了,在VIM的Normal模式下,所有的键就是功能键了。这个你需要知道。
标记:
● 下面的文字中,如果是 Ctrl-λ我会写成 <C-λ>.
● 以 : 开始的命令你需要输入 <enter>回车,例如 — 如果我写成 :q 也就是说你要输入 :q<enter>.
- 各种插入模式
● a → 在光标后插入
● o → 在当前行后插入一个新行
● O → 在当前行前插入一个新行
● cw → 替换从光标所在位置后到一个单词结尾的字符
- 简单的移动光标
● 0 → 数字零,到行头
● ^ → 到本行第一个不是blank字符的位置(所谓blank字符就是空格,tab,换行,回车等)
● $ → 到本行行尾
● g_ → 到本行最后一个不是blank字符的位置。
● /pattern → 搜索 pattern 的字符串(陈皓注:如果搜索出多个匹配,可按n键到下一个)
- 拷贝/粘贴 (陈皓注:p/P都可以,p是表示在当前位置之后,P表示在当前位置之前)
● P → 粘贴
● yy → 拷贝当前行当行于 ddP
- Undo/Redo
● u → undo
● <C-r> → redo
- 打开/保存/退出/改变文件(Buffer)
● :e <path/to/file> → 打开一个文件
● :w → 存盘
● :saveas <path/to/file> → 另存为 <path/to/file>
● :x, ZZ 或 :wq → 保存并退出 (:x 表示仅在需要时保存,ZZ不需要输入冒号并回车)
● :q! → 退出不保存 :qa! 强行退出所有的正在编辑的文件,就算别的文件有更改。
● :bn 和 :bp → 你可以同时打开很多文件,使用这两个命令来切换下一个或上一个文件。(陈皓注:我喜欢使用:n到下一个文件)
下面,让我们看一下vim是怎么重复自己的:
- . → (小数点) 可以重复上一次的命令
- N<command> → 重复某个命令N次
下面是一个示例,找开一个文件你可以试试下面的命令:
● 2dd → 删除2行
● 3p → 粘贴文本3次
● 100idesu [ESC] → 会写下 “desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu “
● . → 重复上一个命令—— 100 “desu “.
● 3. → 重复 3 次 “desu” (注意:不是 300,你看,VIM多聪明啊).
更强
你要让你的光标移动更有效率,你一定要了解下面的这些命令,千万别跳过。
- NG → 到第 N 行 (陈皓注:注意命令中的G是大写的,另我一般使用 : N 到第N行,如 :137 到第137行)
- gg → 到第一行。(陈皓注:相当于1G,或 :1)
- G → 到最后一行。
- 按单词移动:
● w → 到下一个单词的开头。
● e → 到下一个单词的结尾。
> 如果你认为单词是由默认方式,那么就用小写的e和w。默认上来说,一个单词由字母,数字和下划线组成(陈皓注:程序变量)
> 如果你认为单词是由blank字符分隔符,那么你需要使用大写的E和W。(陈皓注:程序语句)
● % : 匹配括号移动,包括 (, {, [. (陈皓注:你需要把光标先移到括号上)
● * 和 #: 匹配光标当前所在的单词,移动光标到下一个(或上一个)匹配单词(*是下一个,#是上一个)
相信我,上面这三个命令对程序员来说是相当强大的。
更快
你一定要记住光标的移动,因为很多命令都可以和这些移动光标的命令连动。很多命令都可以如下来干:
<start position><command><end position>
例如 0y$ 命令意味着:
● 0 → 先到行头
● y → 从这里开始拷贝
● $ → 拷贝到本行最后一个字符
你可可以输入 ye,从当前位置拷贝到本单词的最后一个字符。
你也可以输入 y2/foo 来拷贝2个 “foo” 之间的字符串。
还有很多时间并不一定你就一定要按y才会拷贝,下面的命令也会被拷贝:
● d (删除 )
● v (可视化的选择)
● gU (变大写)
● gu (变小写)
● 等等 (陈皓注:可视化选择是一个很有意思的命令,你可以先按v,然后移动光标,你就会看到文本被选择,然后,你可能d,也可y,也可以变大写等)
第四级 – Vim 超能力
你只需要掌握前面的命令,你就可以很舒服的使用VIM了。但是,现在,我们向你介绍的是VIM杀手级的功能。下面这些功能是我只用vim的原因。
在当前行上移动光标: 0 ^ $ f F t T , ;
● 0 → 到行头
● ^ → 到本行的第一个非blank字符
● $ → 到行尾
● g_ → 到本行最后一个不是blank字符的位置。
● fa → 到下一个为a的字符处,你也可以fs到下一个为s的字符。
● t, → 到逗号前的第一个字符。逗号可以变成其它字符。
● 3fa → 在当前行查找第三个出现的a。
● F 和 T → 和 f 和 t 一样,只不过是相反方向。
还有一个很有用的命令是 dt” → 删除所有的内容,直到遇到双引号—— “。
区域选择 <action>a<object> 或 <action>i<object>
在visual 模式下,这些命令很强大,其命令格式为
<action>a<object> 和 <action>i<object>
● action可以是任何的命令,如 d (删除), y (拷贝), v (可以视模式选择)。
● object 可能是: w 一个单词, W 一个以空格为分隔的单词, s 一个句字, p 一个段落。也可以是一个特别的字符:”、 ‘、 )、 }、 ]。
假设你有一个字符串 (map (+) (“foo”)).而光标键在第一个 o 的位置。
● vi” → 会选择 foo.
● va” → 会选择 “foo”.
● vi) → 会选择 “foo”.
● va) → 会选择(“foo”).
● v2i) → 会选择 map (+) (“foo”)
● v2a) → 会选择 (map (+) (“foo”))
块操作: <C-v>
块操作,典型的操作: 0 <C-v> <C-d> I– [ESC]
● ^ → 到行头
● <C-v> → 开始块操作
● <C-d> → 向下移动 (你也可以使用hjkl来移动光标,或是使用%,或是别的)
● I– [ESC] → I是插入,插入“–”,按ESC键来为每一行生效。
在Windows下的vim,你需要使用 <C-q> 而不是 <C-v> ,<C-v> 是拷贝剪贴板。
自动提示: <C-n> 和 <C-p>
在 Insert 模式下,你可以输入一个词的开头,然后按 <C-p>或是<C-n>,自动补齐功能就出现了……
宏录制: qa 操作序列 q, @a, @@
● qa 把你的操作记录在寄存器 a。
● 于是 @a 会replay被录制的宏。
● @@ 是一个快捷键用来replay最新录制的宏。
示例
在一个只有一行且这一行只有“1”的文本中,键入如下命令:
● qaYp<C-a>q→
● qa 开始录制
● Yp 复制行.
● <C-a> 增加1.
● q 停止录制.
● @a → 在1下面写下 2
● @@ → 在2 正面写下3
● 现在做 100@@ 会创建新的100行,并把数据增加到 103.
可视化选择: v,V,<C-v>
前面,我们看到了 <C-v>的示例 (在Windows下应该是<C-q>),我们可以使用 v 和 V。一但被选好了,你可以做下面的事:
● J → 把所有的行连接起来(变成一行)
● < 或 > → 左右缩进
● = → 自动给缩进 (陈皓注:这个功能相当强大,我太喜欢了)
在所有被选择的行后加上点东西:
● <C-v>
● 选中相关的行 (可使用 j 或 <C-d> 或是 /pattern 或是 % 等……)
● $ 到行最后
● A, 输入字符串,按 ESC。
分屏: :split 和 vsplit.
下面是主要的命令,你可以使用VIM的帮助 :help split. 你可以参考本站以前的一篇文章VIM分屏。
● :split → 创建分屏 (:vsplit创建垂直分屏)
● <C-w><dir> : dir就是方向,可以是 hjkl 或是 ←↓↑→ 中的一个,其用来切换分屏。
● <C-w>_ (或 <C-w>|) : 最大化尺寸 (<C-w>| 垂直分屏)
● <C-w>+ (或 <C-w>-) : 增加尺寸
● 其在线帮助文档中你应该要仔细阅读的是 :help usr_02.txt.
● 你会学习到诸如 !, 目录,寄存器,插件等很多其它的功能。
移动光标类命令 h :光标左移一个字符 l :光标右移一个字符 space:光标右移一个字符 Backspace:光标左移一个字符 k或Ctrl+p:光标上移一行 j或Ctrl+n :光标下移一行 Enter :光标下移一行 w或W :光标右移一个字至字首 b或B :光标左移一个字至字首 e或E :光标右移一个字至字尾 ) :光标移至句尾 ( :光标移至句首 }:光标移至段落开头 {:光标移至段落结尾
- nG:光标移至第n行首
n+:光标下移n行 n-:光标上移n行 n$:光标移至第n行尾 H :光标移至屏幕顶行 M :光标移至屏幕中间行 L :光标移至屏幕最后行 0:(注意是数字零)光标移至当前行首 $:光标移至当前行尾
屏幕翻滚类命令 Ctrl+u:向文件首翻半屏 Ctrl+d:向文件尾翻半屏 Ctrl+f:向文件尾翻一屏 Ctrl+b;向文件首翻一屏 nz:将第n行滚至屏幕顶部,不指定n时将当前行滚至屏幕顶部。
插入文本类命令 i :在光标前 I :在当前行首 a:光标后 A:在当前行尾 o:在当前行之下新开一行 O:在当前行之上新开一行 r:替换当前字符 R:替换当前字符及其后的字符,直至按ESC键 s:从当前光标位置处开始,以输入的文本替代指定数目的字符 S:删除指定数目的行,并以所输入文本代替之 ncw或nCW:修改指定数目的字 nCC:修改指定数目的行
删除命令 ndw或ndW:删除光标处开始及其后的n-1个字 do:删至行首 d$:删至行尾 ndd:删除当前行及其后n-1行 x或X:删除一个字符,x删除光标后的,而X删除光标前的 Ctrl+u:删除输入方式下所输入的文本
搜索及替换命令 /pattern:从光标开始处向文件尾搜索pattern ?pattern:从光标开始处向文件首搜索pattern n:在同一方向重复上一次搜索命令 N:在反方向上重复上一次搜索命令 :s/p1/p2/g:将当前行中所有p1均用p2替代 :n1,n2s/p1/p2/g:将第n1至n2行中所有p1均用p2替代 :g/p1/s//p2/g:将文件中所有p1均用p2替换
选项设置 all:列出所有选项设置情况 term:设置终端类型 ignorance:在搜索中忽略大小写 list:显示制表位(Ctrl+I)和行尾标志($) number:显示行号 report:显示由面向行的命令修改过的数目 terse:显示简短的警告信息 warn:在转到别的文件时若没保存当前文件则显示NO write信息 nomagic:允许在搜索模式中,使用前面不带“\”的特殊字符 nowrapscan:禁止vi在搜索到达文件两端时,又从另一端开始 mesg:允许vi显示其他用户用write写到自己终端上的信息
最后行方式命令 :n1,n2 co n3:将n1行到n2行之间的内容拷贝到第n3行下 :n1,n2 m n3:将n1行到n2行之间的内容移至到第n3行下 :n1,n2 d :将n1行到n2行之间的内容删除 :w :保存当前文件 :e filename:打开文件filename进行编辑 :x:保存当前文件并退出 :q:退出vi :q!:不保存文件并退出vi :!command:执行shell命令command :n1,n2 w!command:将文件中n1行至n2行的内容作为command的输入并执行之,若不指定n1,n2,则表示将整个文件内容作为command的输入 :r!command:将命令command的输出结果放到当前行
寄存器操作 “?nyy:将当前行及其下n行的内容保存到寄存器?中,其中?为一个字母,n为一个数字 “?nyw:将当前行及其下n个字保存到寄存器?中,其中?为一个字母,n为一个数字 “?nyl:将当前行及其下n个字符保存到寄存器?中,其中?为一个字母,n为一个数字 “?p:取出寄存器?中的内容并将其放到光标位置处。这里?可以是一个字母,也可以是一个数字 ndd:将当前行及其下共n行文本删除,并将所删内容放到1号删除寄存器中。
vi 复制粘贴详解 (2009-07-14 14:33:17) 转载▼ 标签: 杂谈 分类: 资料精选
转自:http://woodvillage.blogbus.com/logs/34811481.html
多方搜索整理如下:(除特殊说明以下操作均在命令模式下)
1.
将光标移动到将要复制的行处,按yy进行复制当前行(按nyy复制n行),再移动到粘贴位置,按p进行粘贴。
2.
将光标移到复制的首位置,按下v,用hjkl移动,按y复制,按p粘贴。
3.
光标移到起始行,输入ma;光标移到结束行,输入mb;光标移到粘贴行,输入mc;然后 :’a,’b co ‘c,把 co 改成 m 就成剪切了。
4.
光标移动到要复制的行,输入yny(n表示要复制该行以下n行);光标移动到粘贴行,按p粘贴。
5.
直接输入:n1,n2 co n3。(n1为起始行,n2为结束行,n3为粘贴行)
6.
不同文件之间的复制:用:sp [filename]打开另一文件,(用^ww在文件之间切换),然后按上述方法复制
有关的命令如下: yy 将当前行复制到缓冲区 yw 将当前单词复制到缓冲区 y1 将光标处的一个字符复制到缓冲区 p 将缓冲区的信息粘贴到光标的后面 :行号1 ,行号2 copy 行号3 将行号1到行号2的内容复制到行号3所在行的后面。 :行号1 ,行号2 move 行号3 将行号1到行号2的文本内容移动到行号3所在行的后面。
7.
寄存器操作 寄存器操作
“?nyy: 将当前行及其下n行的内容保存到寄存器?中,其中?为一个字母,n为
一个数字
“?nyw: 将当前行及其下n个字保存到寄存器?中,其中?为一个字母,n为一个
数字
“?nyl: 将当前行及其下n个字符保存到寄存器?中,其中?为一个字母,n为一
个数字
“?p: 取出寄存器?中的内容并将其放到光标位置处。这里?可以是一个字母
,也可以是一个数字
ndd: 将当前行及其下共n行文本删除,并将所删内容放到1号删除寄存器中
vi多个文件之间复制、粘贴
打开和切换文件 步骤
1、vi 12、:e 2 打开文件2
3、用:e#在两个文件间切换。
复制和粘贴文件 步骤
1、回到1文件,先在开始处做标志mk 然后在末尾用”ay’k (光标自动回到开始处,此时已经把你的内容放到缓冲区了) 其中a表示缓冲区a
2、用:e#切换到文件2,找到你要粘贴的位置,然后用”ap命令粘贴就行