自定义代码段在sublime text 3中不起作用

时间:2015-07-12 09:36:39

标签: sublimetext3

我正在使用以下代码在崇高文本3中创建自定义代码段但是当我按下tabTrigger

键入我的愿望tab时,它无法正常工作
<snippet>
<content><![CDATA[alter pot water it your pot.]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>alter</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.html</scope>
<!-- Optional: Description to show in the menu -->
<description>My Fancy Snippet</description>
</snippet>

之后我在html文档中输入alter并按tab但没有显示内容。你能告诉我为什么吗?

5 个答案:

答案 0 :(得分:4)

原因是范围错误,需要text.html

另外请确保为自动填充启用了文本范围(默认情况下它不是't)。转到首选项&gt;设置 - 用户,然后将text(或text.html仅限HTML)添加到auto_complete_selector

答案 1 :(得分:2)

Sublime Text 3 - Snippet doesn't fire on tab, only on CSS file

简而言之

更改

<tabTrigger>alter</tabTrigger>

<tabTrigger>alter/</tabTrigger>

答案 2 :(得分:2)

<scope>标记的内容有误。要确定光标下的当前范围,请在Sublime控制台中运行以下命令:

view.scope_name(view.sel()[0].begin())

要在Windows上调出控制台,请按Ctrl +'

答案 3 :(得分:0)

除了上面的信息之外,我还要确保您要打开的文档是Sublime文本中的HTML文档。看右下角。当我第一次开始使用自定义代码段时,他们没有工作,这是因为Sublime中的默认文件类型是纯文本。您可以单击右下角将文档更改为正确的文件类型。

答案 4 :(得分:0)

这对我有用。我在Win 8.1中使用Sublime Text Build 3083

<snippet>
    <content><![CDATA[console.log();]]></content>
    <!-- Optional: Tab trigger to activate the snippet -->
    <tabTrigger>cl</tabTrigger>
    <!-- Optional: Scope the tab trigger will be active in -->
    <scope>text.html</scope>
    <!-- Optional: Description to show in the menu -->
    <description>JS Console Log</description>
</snippet>

你可以尝试一下。

相关问题