Babu
Babu

Reputation: 455

custom snippet is not working in sublime text 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 ?

Upvotes: 3

Views: 4274

Answers (5)

Mofizul Islam
Mofizul Islam

Reputation: 91

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.

Upvotes: 0

awatts
awatts

Reputation: 1067

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+'

Upvotes: 4

Jhan330
Jhan330

Reputation: 1

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.

Upvotes: 0

duoh
duoh

Reputation: 41

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

in short

change

<tabTrigger>alter</tabTrigger>

to

<tabTrigger>alter/</tabTrigger>

Upvotes: 4

idleberg
idleberg

Reputation: 12882

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.

Upvotes: 4

Related Questions