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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值