Sublime text3 添加代码片段

创建方法:Tools (工具)> Developer > New Snippet(新片段)

此时,会出现如下代码:

[html]  view plain  copy
  1. <snippet>  
  2.     <content><![CDATA[ 
  3. Hello, ${1:this} is a ${2:snippet}. 
  4. ]]></content>  
  5.     <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->  
  6.     <!-- <tabTrigger>hello</tabTrigger> -->  
  7.     <!-- Optional: Set a scope to limit where the snippet will trigger -->  
  8.     <!-- <scope>source.python</scope> -->  
  9. </snippet>  

 其中,content中由CDATA包裹起来的部分是我们要插入的代码片段,可选。


tabTrigger是我们tab键触发的自动补全代码功能的一个名字,可选。


scope,可选,使用范围,不填写代表对所有文件有效。附:source.css和test.html分别对应不同文件。


description,可选,在snippet菜单中的显示说明(支持中文)。如果不定义,菜单则显示当前文件的文件名。


${1:this}表示代码插入后,光标所停留的位置,可同时插入多个。其中:this为自定义参数(可选)。
${2}表示代码插入后,按Tab键,光标会根据顺序跳转到相应位置(以此类推)。


然后保存代码片段,保存到Sublime Text3\Data\Packages\User下面(直接Ctrl+s),取个名字 注意。产生的文件后缀名位.sublime-snippet
版权声明:在保留作者及本博客链接的情况下,可以尽情转载! https://blog.csdn.net/Admin_yi/article/details/53671726

猜你喜欢

转载自blog.csdn.net/weixin_37657720/article/details/80513230