Sublime Forum

Snippets

#1

OK let’s say I have a page with a .php extension but consisting mainly of html code. Now I want to insert a snippet of php like this:

 <?php echo "Hello world";  ?>

php tags and all.

How can I do that in ST2? As far as I can see it will only let me insert this if I am already between php tags on the page which defeats the object.

Help please…

Same thing happens if I set it up as an emmet abbreviation by the way.

0 Likes

#2

You would use the scope text.html.basic. Modified from the default snippet:

<snippet> <content><![CDATA[ Hello, ${1:this} is a ${2:snippet}. ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <!-- <tabTrigger>hello</tabTrigger> --> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>text.html.basic</scope> </snippet>

0 Likes

#3

Many thanks!

0 Likes