如何在崇高文本2中创建片段

时间:2013-05-18 11:58:33

标签: sublimetext2 code-snippets

<snippet>
    <content>
        <!doctype html>
<html>

<head>
        <style type = "text/css">

        </style>
</head>

<body>
        <script type = "text/javascript">

        </script>
</body>

</html>
    </content>
    <tabTrigger>html_t</tabTrigger>
    <description>html_css_javascript</description>
    <scope>html</scope>
</snippet>

当我将其另存为h.sublime-snippet时,我收到错误“Snippet Packages /User/h.sublime-snippet没有内容”

2 个答案:

答案 0 :(得分:3)

<snippet>
    <content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
    <!-- 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> -->
</snippet>

如果您将自己与此示例中的代码进行比较,您会发现自己缺少一些关键组件 - 例如,<![CDATA[然后是您的html代码,然后是]]>

答案 1 :(得分:0)

这是一个制作片段(html评论)的示例,通过点击c +标签触发:

<snippet>
    <content><![CDATA <!-- ${1:comment} -->]</content>
    <!-- Optional: Tab trigger to activate the snippet -->
    <tabTrigger>c</tabTrigger>
    <description>Snippet to make fast html comment</description>
</snippet>