PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

sublime Snippet如何编写

藏色散人
藏色散人 转载
2021-07-05 16:21:19 2249浏览

下面由sublime教程栏目给大家介绍sublime snippet如何编写!

sublime Snippet编写

    <snippet>
        <content></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <!-- <tabTrigger>hello</tabTrigger> -->
        <tabtrigger>hello</tabtrigger>
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <!-- <scope>source.python</scope> -->
        <scope>text.html</scope>
        <description>Hellossssssssssssssssssssssssssssssssssssssss My test.</description>
    </snippet>

snippet是片段的意思,就是说智能提示的概念。

content是片段内容,scope标签是触发的文件类型,tagTrigger是触发的关键字,description是注释说明

他和macro的区别是:
宏的操作都是需要用快捷键的,而且保存的宏必须加载在系统keymap文件user自定义部分当中。
eg:

对已经保存的宏的操作:

[      { "keys": ["ctrl+shift+;"], "command": "run_macro_file", "args": {"file": "res://Packages/User/test.sublime-macro"} }  ]
 而snippet操作是用于只能提示,只要文件保存了系统就会自动加载,不需要keymap。

但是,marco是对多个操作的统一规划,而snippet只是只能提示罢了。
也就是说当你需要一堆有顺序的按键操作的时候,使用marco,记录宏实际上就是记录你的按键顺序。
而当你想加载一个模板或者智能提示时,用snippet

效果如图所示

97b0b5c81afff185237cba0bbc18177.png

声明:本文转载于:segmentfault,如有侵犯,请联系admin@php.cn删除