命令
- M-x yas-new-snippet
- M-x yas-visit-snippet-file 打开片段文件
- M-x snippet-mode
语法
1
2
3
4
5
|
# key: snippet abbrev 代码片段缩写
# name: snippet name 代码段名称,它将显示在菜单中
# condition: snippet condition 则仅当条件代码的计算结果为某个非 nil 值时,才会展开该代码段
# binding: direct keybinding
# type: snippet or command 如果 type 指令设置为 command ,则代码段的主体被解释为 Lisp 代码
|
1
2
3
4
5
6
7
8
9
10
11
|
# expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil)) 绘图
welcome to my
X humble
/ \ home,
/ \ $0
/ \
/-------\
| |
| +-+ |
| | | |
+--+-+--+
|
Template Syntax 模板语法
代码段模板的语法简单但功能强大,与 TextMate 的语法非常相似。
- Plain Text 纯文本 ,除 $ ,` 和 \ 外的文本会直接输出,需要转义
- Embedded Emacs Lisp code elisp 代码写在反引号 (` ) 内
Emacs lisp code
1
2
|
`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`
;;文件名大写
|