3

I am creating a custom snippet in sublime text 3 with following code but somehow it's not working when I type my desire tabTrigger with pressing the tab

<snippet>
<content><![CDATA[alter pot water it your pot.]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>alter</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.html</scope>
<!-- Optional: Description to show in the menu -->
<description>My Fancy Snippet</description>
</snippet>

after that Im typing alter in html document and pressing tab but doesn't showing the content. can you tell me why ?

5 Answers 5

4

The reason is the wrong scope, it needs to be text.html.

Also make sure, the text scope is enabled for autocompletions (by default it isn't). Go to Preferences>Settings - User and add text (or text.html for HTML only) to auto_complete_selector.

Sign up to request clarification or add additional context in comments.

2 Comments

You probably have to enable completions for the text scope, see my edited answer
You can also enable the autocomplete selector everywhere by setting the autocomplete selector config option in Preferences>Settings - User to true: i.e..: "auto_complete_selector": true
4

Sublime Text 3 - Snippet doesn't fire on tab, only on CSS file

in short

change

<tabTrigger>alter</tabTrigger>

to

<tabTrigger>alter/</tabTrigger>

Comments

4

The content of your <scope> tag is wrong. To determine the current scope under your cursor, run the following in the Sublime console:

view.scope_name(view.sel()[0].begin())

To bring up the console on Windows, press Ctrl+'

Comments

0

I would also make sure, in addition to the information above, that the document that you are opening is an HTML document in Sublime text. Look in the bottom right hand corner. When I first started using the custom snippets they didn't work and it was because the default file type in Sublime is plain text. You can click on the bottom right to change the document to the proper file type.

1 Comment

please follow thus [URL]( stackoverflow.com/help) it will be useful to raise your content quality up
0

It's working for me. I'm using Sublime Text Build 3083 in Win 8.1

<snippet>
    <content><![CDATA[console.log();]]></content>
    <!-- Optional: Tab trigger to activate the snippet -->
    <tabTrigger>cl</tabTrigger>
    <!-- Optional: Scope the tab trigger will be active in -->
    <scope>text.html</scope>
    <!-- Optional: Description to show in the menu -->
    <description>JS Console Log</description>
</snippet>

You can try it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.