我刚刚编写了以下代码段,并将其保存在Packages/User/HTML文件夹中,作为"add-script-source.sublime-snippet".
<snippet>
<content><![CDATA[
<script type="text/javascript" src="${1:script.js}">${2}</script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>scriptsrc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
</snippet>
Run Code Online (Sandbox Code Playgroud)
现在,我只想让这个片段在HTML文件中工作,但事实并非如此.如果我注释掉"scope"标记,它将在JavaScript中工作,但仍然不在HTML中.我的印象是,User文件夹下面的文件夹名称也为Sublime Text提供了适当的范围(如本视频中所述https://tutsplus.com/lesson/your-first-snippet/),这不会出现做任何事.每当我将范围标记设置为ANYTHING时,代码段都不会触发.
问题可能是什么?
AGS*_*AGS 18
"只是有用的sublime文本自动完成没有出现,就像在其他语言中一样.有谁知道为什么会这样?"
您需要将其添加到您的Packages/User/Preferences.sublime-settings文件中.
"auto_complete_selector": "source, text"
Run Code Online (Sandbox Code Playgroud)
然后在代码段文件中给它一个描述:
<snippet>
<content><![CDATA[
<script type="text/javascript" src="${1:script.js}">${2}</script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>scriptsrc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
<description>scriptsrc</description>
</snippet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5045 次 |
| 最近记录: |