SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from TextMate's syntax, you can even import most TextMate templates to YASnippet
download https://github.com/capitaomorte/yasnippet
then put below to .emacs
;;YASnippet
(add-to-list 'load-path "/home/ryu/emacs/site/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
(yas--initialize)
(yas/load-directory "/home/ryu/emacs/site/yasnippet/snippets")
How to Use Yasnippet?
Insert a template by using the menu.
Insert a template by typing the abbreviation, then press Tab.
Find Out What Templates Are Available
1: when coding HTML. YASnippet->html-mode->submenu -> 〖<body>…</body>〗 ->“body =>” it means type body -> press Tab -> it'll expand to <body> </body>.
2: folder /snippets/html-mode/-> a list of files.the first part before “.”, is the abbreviation you can use.
#name : is for a short title for the template.
# -- : Everything above that line is either comment or directive. Below the line is the actual template definition.
自定義模板
1:當在文件中,不指明key的話,文件名中不論有沒有點號,都是作爲一個整體作爲標識。只要文件名不一樣就是不同的模板,內容無視。
2:但是當你在文件中指定了key的話,只要內部name一樣,它們就會互相覆蓋。前提是name不一樣,它纔會展現出來,並且這個時候key作爲標識。
Emacswiki
http://emacswiki.org/Yasnippet
http://blog.waterlin.org/articles/emacs-yasnippet-basic-usage.html