Sublime Snippet不工作

mtp*_*ltz 13 sublimetext3

我只是想制作一些片段,但我不能让它们中的任何一个工作.有人能看出这有什么问题吗?我阅读了他们的文档,并在网上翻阅了一些例子,但它们也没有用.我已经在我的/sublime text 3/packages/user文件夹中找到它并使用约定命名myTest.sublime.snippet.

该片段是:

<snippet>
    <content>
<![CDATA[
<!DOCTYPE html lang="en">
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <title>${1:test1|test2|test3} | $2</title>
    <meta name="viewport" content="width=device-width">
    <meta name="Description" lang="en" content="Description">
    <meta name="robots" content="index, follow">
    <meta name="robots" content="noodp, noydir">

    <!-- Twitter Bootstrap -->
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <script src="assets/js/respond.min.js"></script>
    <![endif]-->    
</head>
<body>

    <div class="container">
        $3
    </div>

</body>
</html>
]]>
</content>
    <tabTrigger>page</tabTrigger>
    <scope>source.html</scope>
    <description>HTML5 Base HTML</description>
</snippet>
Run Code Online (Sandbox Code Playgroud)

awe*_*oon 11

您应该使用text.html,而不是source.htmlscope块.

  • 奇怪的是。我将您的示例复制粘贴到“HTML”文件夹中,将“source”更改为“text”,代码片段就可以工作了。尝试解压默认的“HTML.sublime-package”,更改代码片段中的某些内容,将其放入“User”或“User/HTML”文件夹中并尝试调用。也尝试重新启动ST3。 (2认同)

Kri*_*ian 10

Sublime 3需要片段才能在文件名中包含.sublime-snippet结尾.

  • 这应该标记为正确的答案. (2认同)

小智 9

第1步。对于 html 片段,请更改

<scope>source.html</scope>
Run Code Online (Sandbox Code Playgroud)

<scope>text.html</scope>
Run Code Online (Sandbox Code Playgroud)

第2步。如果您希望 sublime 在输入关键字后显示工具提示,请添加此行

"auto_complete_selector": true
Run Code Online (Sandbox Code Playgroud)

到您的首选项 - 设置用户文件


小智 5

您应该在代码段中转义美元符号。$ -> \$。