适用版本: Emacs 24+
.emacs
或者 .emacs.d/init.el
1
2
3
4
5
6
7
8
;; set packages
(require 'package)
(setq package-archives
'(("original" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
M-x eval-buffer
M-x package-list-packages
按照你的网速快慢,可能需要半分钟左右.yasnippet
yasnippet-bundle
yas-jit
, 并按i
(install)
标记安装.最后按x
安装。
PS:
yasnippet-bundle
(可选) – 自动编译snippetsyas-jit
(可选) – 按需加载snippets配置yasnippet,这里分两种情况: 安装yas-jit和没有安装yas-jit:
yas-int
1
2
3
4
5
6
7
8
9
10
11
12
(require 'yas-jit)
(require 'dropdown-list)
(setq yas/prompt-functions '(
yas/ido-prompt
yas/dropdown-prompt
yas/completing-prompt))
(setq yas/root-directory '(
"~/.emacs.d/snippets" ;; 自己的snippets
"~/.emacs.d/elpa/yasnippet-20121127.25/snippets" ;; yasnippet提供的
"~/.emacs.d/vendor/yasnippets-rails/rails-snippets" ;; 其他
"~/.emacs.d/vendor/yasnippets-shoulda"))
(yas/jit-load)
yas-jit
1
2
3
4
5
6
7
8
(require 'yasnippet)
(yas-global-mode 1)
(require 'dropdown-list)
(setq yas/prompt-functions '( yas/ido-prompt
yas/dropdown-prompt
yas/completing-prompt))
(yas/load-directory "~/.emacs.d/vendor/yasnippets-rails/rails-snippets")
(yas/load-directory "~/.emacs.d/vendor/yasnippets-shoulda")
欢迎参考我的emacs-config
TAB
被绑定到了 markdown-cycle
上,所以无法展开snippets。
查看键绑定C-h k RET TAB
TAB runs the command markdown-cycle, which is an interactive compiled Lisp function in ‘markdown-mode.el’.