当我只定义了三个字段时,为什么我的sublime片段中有四个字段?

时间:2016-05-25 22:02:30

标签: sublimetext3

我有以下代码段:

<snippet>
    <content><![CDATA[
### ${1:title}
#### ${2:sub title}
${3:summary}
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>qnote</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>

它运行正常,除非我调用它时,sublime正在寻找4个标签字段而不是3个,所以当我完成填写摘要时,我必须再次点击标签填充第四个字段。为什么会发生这种情况?如何更改行为以便只有三个选项卡字段?谢谢! enter image description here

1 个答案:

答案 0 :(得分:0)

默认情况下,片段末尾包含一个额外隐藏的“字段”,因此您可以按 Tab 将光标移动到片段结尾之后,无论最后一个字段位于何处在片段中定义。

因此,您可能希望更改代码段以删除${3:summary},以便它看起来像这样:

<snippet>
    <content><![CDATA[
### ${1:title}
#### ${2:sub title}
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>qnote</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>

它会按照你想要的方式行事。