Home Download Buy Blog Forum Support

Snippet not working

Snippet not working

Postby curiouslearn on Wed Dec 28, 2011 2:20 pm

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

Code: Select all
<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
Code: Select all
Sublime Text 2/Packages/HTML
and
Code: Select all
Sublime Text 2/Packages/User
folders using the filename
Code: Select all
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: Select all
<snippet>
   <content><![CDATA[
<!-- $1 -->
]]></content>
   <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
   <tabTrigger>com</tabTrigger>
   <!-- Optional: Set a scope to limit where the snippet will trigger -->
   <scope>source.html</scope>
</snippet>


Thanks in advance for your help.
curiouslearn
 
Posts: 5
Joined: Wed Dec 28, 2011 2:10 pm

Re: Snippet not working

Postby C0D312 on Wed Dec 28, 2011 6:18 pm

Try saving this to your User folder:

Code: Select all
<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
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Snippet not working

Postby curiouslearn on Fri Dec 30, 2011 5:25 am

Thanks so much! This worked great.
curiouslearn
 
Posts: 5
Joined: Wed Dec 28, 2011 2:10 pm


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 8 guests