BanksySan
BanksySan

Reputation: 28510

Sublime snippet not scoping to HTML

I have the following snippet:

<snippet>
    <content><![CDATA[
<label for="my-id">Name:</label>
<input type="text" id="my-name" name="my-name" value="enter your name" />
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>htmlLabel</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>text.html</scope> 
    <description>Html Label and input</description>
</snippet>

It should be scoped to HTML. It's not there when I'm in C# or Plain Text but is IS there in Markdown.

Upvotes: 0

Views: 34

Answers (1)

Saad
Saad

Reputation: 53849

There are two ways you can fix this issue:

  1. Change your scope to text.html.basic

  2. Change your scope to text.html -text.html.markdown

Markdown is just a shorthand syntax for HTML. The scope for markdown is actually just text.html.markdown. You have text.html specified as your scope, so all the children of text.html are going to have access to the snippet as well.

If you want to specify a snippet for only plain HTML, you have to specify that you only want text.html.basic (the first method I showed), or you can negate certain scopes by using the - symbol (the second method I showed).

Here is a good resource where you can see all of the different types of scope for Sublime.

Upvotes: 2

Related Questions