Sublime Forum

Snippet not working

#1

Can you please see the snippet below and tell me why it is not working? I cannot figure it out. I have another very similar snippet which works well. Both are included below.

This snippet does not work

<snippet> <content><![CDATA[ <span class="code"> $1 </span> ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>spcode</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>source.html</scope> </snippet>

I have saved the above in both Sublime Text 2/Packages/HTML and Sublime Text 2/Packages/User folders using the filename span_classcode.sublime-snippet. Do I need to restart sublime text 2 for the program to recognize snippets? Is some refresh or reload necessary? Thanks.

The following snippet works

[code]
<![CDATA[

]]>

com

source.html
[/code]

Thanks in advance for your help.

0 Likes

#2

Try saving this to your User folder:

<snippet> <content><![CDATA[ <span class="code"> $1 </span> ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>spcode</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>text.html</scope> </snippet>

Where is says scope, I changed it to text.html. To check what scope you want for a snippet, you can press Ctrl+Alt+P on Windows and Linux, Command+Option+P on OSX). This will show the current scope in the status bar. If you open an html file and press this command, it will tell you what should be added to the scope of the snippet.

Hope that helps

0 Likes

#3

Thanks so much! This worked great.

0 Likes