Sublime Forum

ST3 Snippet for a CSS source

#1

Hello,
I would like to create this snippet, but i want that it works only in a CSS Source, because it works
in all types of source

<![CDATA[
/--------------------------------------------------\

*--------------------------------------------------*/
]]>
cc



Best Regards

0 Likes

#2

In order to have a snippet only apply in a specific context, you need to set the scope in the snippet to match the scope you’re interested in.

If you position the cursor at a point where you want the snippet to trigger (e.g. inside of a CSS file), you can choose Tools > Developer > Show Scope Name (or press the associated key; check the menu for what it’s set to for you), Sublime will tell you the scope.

The scope you see will have one or more parts separated by spaces; roughly speaking the more of them you include, the more specific the scope becomes.

In your case, your snippet would probably look something like the following (although you need to replace the tab trigger as appropriate). This sets the scope so that it triggers anywhere inside a CSS file.

<snippet>
    <content><![CDATA[
/*--------------------------------------------------*\

*--------------------------------------------------*/
]]></content>
    <tabTrigger>whatever</tabTrigger>
    <scope>source.css</scope>
</snippet>
0 Likes