Home > Development Tools > sublime > body text

How to write sublime Snippet

藏色散人
Release: 2021-07-05 16:21:19
forward
2490 people have browsed it

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

How to write 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>
Copy after login

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

效果如图所示

How to write sublime Snippet

The above is the detailed content of How to write sublime Snippet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template