Reputation: 553
Here's the default auto-completion for "switch":
switch (variable) {
case 'value':
# code...
break;
default:
# code...
break;
}
but I wish to turn it into just:
switch ()
{
case '':
break;
case '':
break;
}
because I don't like to modify "#code here..." every time.
I navigated to
"C:\Users\USER\AppData\Roaming\Sublime Text 2\Packages\PHP"
and opened "switch(-).sublime-snippet" and modified it into:
<snippet>
<content><![CDATA[switch ($0)
{
case '$0':
break;
case '$0':
break;
}]]></content>
<tabTrigger>switch</tabTrigger>
<scope>source.php</scope>
<description>switch …</description>
But nothing works.
Is there any syntax error?
Or do I modify the wrong file?
Upvotes: 0
Views: 1297
Reputation: 102862
If you tagged your question correctly, you modified the wrong file - you need to edit the Sublime Text 3 version. This is a bit more difficult to do directly, since the file is wrapped up in a .sublime-package
zip archive. To get around this, install Package Control (if you haven't already), then install the PackageResourceViewer
plugin. Open the Command Palette, type prv
to bring up the PackageResourceViewer
options, select Open Resource
, then navigate down to PHP
and select the switch(-).sublime-snippet
option. Edit it to your liking, save it, and you should be all set.
You probably also want to set your tab stops differently. Try this instead:
<snippet>
<content><![CDATA[switch ($1)
{
case '$2':
$3
break;
case '$4':
$5
break;
${0:default:}
}]]></content>
<tabTrigger>switch</tabTrigger>
<scope>source.php</scope>
<description>switch …</description>
</snippet>
Now, you can tab through the different areas, filling in the info as you go, ending up at the bottom with a default
option, that you can just hit Delete on to erase if you don't want it. With your original version, after typeing switch
Tab, you would have ended up with 3 different cursors, one at each of the $0
locations. Check out the snippets reference for more information.
Upvotes: 2