<tabTrigger>hisnip</tabTrigger>
<description>Test Snippet</description>
<scope>js, php</scope>
<!-- 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> -->
如何将mySnippet.sublime-snippet文件导入到sublime设置中,这样我就可以始终访问该代码段而无需添加到JS和PHP代码段默认文件中。
这是在 Sublime 中创建代码段的方法吗?我想要一个包含我的自定义代码段的代码段文件,并可能将其优先级设置为默认值以上。但似乎sublime没有用户代码段和默认代码段json。
最佳答案
首先,最重要的是:您的摘要可能不会做很多事情。您将需要通过以下方式对其进行格式化:
<snippet>
<content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>hisnip</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
<scope>source.php</scope>
</snippet>
要开始创建新的代码段,请进入菜单栏中的工具>新建代码段。这将创建一个具有默认选项和格式的新代码段。您可以获得完整的自定义选项from the docs列表。
创建并自定义代码段后,转到 Sublime Text>首选项>浏览软件包... 并将代码段保存在用户目录中:
请注意,摘要的正确文件扩展名是
.sublime-snippet
。您可能还需要重新启动Sublime Text才能加载该片段以供使用。加载到环境中后,您可以通过键入
hisnip
(或封装在<tabTrigger></tabTrigger>
标记之间的任何内容)并按标签键来访问代码段。
关于autocomplete - 如何在Sublime Text中创建片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19828205/