Yasnippet

YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates includes: C, C++, C#, Perl, Python, Ruby,

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

Emacs: Using Templates with YASnippet

Emacs: How to Define Templates in YASnippet

你可能感兴趣的:(python,function,perl,import,templates,textmate)