Reputation: 3571
I'm trying to create a simple snippet in ST2 that will be expanded when I type in a bit of text and hit tab.
I've gone to 'tools'->'create new snippet'. I've edited the template thus:
<snippet>
<content><![CDATA[
<?php ${1} ?>
]]></content>
<tabTrigger>php</tabTrigger>
<scope>source.php</scope>
</snippet>
I'd like to be able to enter 'php', and have the string expanded as ''.
I've saved the snippet in the default location presented to me when I've hit 'save as'.
However, I'm not getting the desired result. After restarting ST2, and opening a php file, and making sure the file is being read as php, I'm not getting my desired expansion.
How do I get the expansion?
Upvotes: 2
Views: 1516
Reputation: 6420
1. Did you save correctly your snippet file ?
Snippets should be saved as Snippet1.sublime-snippet
, preferably in Packages/User
2. Did your tabTrigger has the same name as another one ?
It is not really an issue, here php
is already used as a snippet by Sublime Text2, since you can choose which one to use, but we're never too careful. Try a different one, like newphp
or phptags
.
3. Did you use Sublime Text 2 Documentation?
For example you can look at Snippets Documentation here.
Your code:
<snippet>
<content><![CDATA[<?php ${1} ?>]]></content>
<tabTrigger>newphp</tabTrigger>
<scope>source.php</scope>
</snippet>
works fine if you save the file as .sublime-snippet
in Packages
.
Upvotes: 2