Sublime Forum

Help with limiting snippet scope to XML

#1

Using this command on the console view.scope_name(view.sel()[0].begin()) I found the scope for the xml to be text.xml. Below is what I have but when I try it in my xml file it does not work. when I type, the suggestion field does not pop up at all.

<snippet>
	<content><![CDATA[
This is my text
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>New xml</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.xml</scope>
</snippet>
0 Likes

#2

In ST3 tab trigger can’t contain whitespace characters; so there the snippet will only be visible if you use the command palette (i.e. there will be an entry named Snippet: FILENAME where FILENAME is the name of the file you saved the snippet as.

In ST4 the situation is better, but whitespace in tab triggers still isn’t really expected, so there you would need to type the word new and then either manually invoke the AC panel or press tab (with the appropriate settings) to invoke it.

In either case, the easiest solution is probably to just to not use spaces in the trigger.

Also, for what it’s worth Tools > Developer > Show Scope Name is a faster and easier way to quickly get at the scope at the current cursor location; there’s a key bound to it which you can see in the menu item.

1 Like

#3

I am not home to try this but thank you so much for your answer. This makes allot of sense now, of course.

Also, for what it’s worth Tools > Developer > Show Scope Name is a faster and easier way to quickly get at the scope at the current cursor location; there’s a key bound to it which you can see in the menu item.

Oh my lord. You will not believe the various forum trawling I did to get at this scope thing. Thanks allot indeed.

1 Like