自定义代码段
为了提升开发速度,在sublime中我们能够自定义代码段,将一些常用的代码存储起来以提升开发效率
菜单项
- 选择菜单中的tool->Developer->NewSnippets 进行创建
设置方式
- 设置方法
- content中写的是 写完生成的东西
- 注意,要写在
<![CDATA[]]>中 否则可能会出现解析错误的问题- ${} 进行占位 生成可供输入的内容
- ${1:} 数字配合: 决定 第几次tab切换到的位置
- ${1:haha} haha 是提示的信息
- tabTrigger
- 设置的是 使用哪种什么字母
- scope
- 设置的是具体在什么文件中呼出
- 如果注释掉 所有语言都可以呼出
- 如果仅限于 html text.html
- 如果css source.css
<snippet>
<content><![CDATA[这里面写要生成的内容${1:first}]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>