Sublime Forum

Snippet Tag Trigger not working

#1

I have created two custom snippets for python code. Here is the text of the snippets:
`

.pt

source.python
python 2 print stmt
`

and

`
") ]]>

.ri

source.python
sets up raw input
`

I saved both to my Packages/User folder and named them print.sublime-snippet and raw_input.sublime-snippet (respectively). They both work fine from the command pallette. Only the tab trigger is not working. I’ve tried to comment out the scope (didn’t work). I’ve tried to change the tab trigger to all kinds of different values (none of them worked). Actually, the raw_input trigger did work one time, but when I tried it again it failed to work and has not worked since (no changes were made between the time it worked and the time it didn’t). I’ve tried restarting Sublime Text (I’m in version 3 on a Mac, btw). I changed “auto_complete_selector”: true in my preferences -> Settings-User file. I’ve read all of the discussions I can find on this issue both on this forum and in stack overflow. Any assistance would be greatly appreciated!

0 Likes

#2

Both seem to work OK for me (on Windows, Mac and Linux). Is the sublime console showing any error messages?

Did you do this before or after you noticed that this doesn’t work? I don’t think true is a valid value for that setting, or at least not one that will do what you want (I may be wrong, though).

0 Likes

#3

I changed the auto_complete_selector after it wasn’t working. Actually, it would be more accurate to say I added that setting to my Settings-user (it was not there at all before). I found that suggestion in several other posts.

The snippets work for me on my other computer. When I type in the “.pt” or “.ri” for the tab completion, sublime is subbing in “raw_input” or “print” instead of the snippet code.

I’m sure I have a setting out of place somewhere, but I can’t figure out where in the world it would be.

0 Likes

#4

That sounds like it’s just picking up the text of the files and picking matching words out of them as completions.

I can’t think of what setting might be messing something like this up for you; the file names seem OK as does the location where you dropped them. Also you clearly know what you’re doing since they work on your other computer.

Have you tried comparing the settings/plugins that you have on both to see what might be different? There are only a small handful of settings that default to something different on a Mac (assuming that the machine they work on is not also a Mac) and I can’t imagine any of them having any effect on this particular issue.

0 Likes

#5

Yes, I finally found a solution. If I make my tag triggers begin with _ , they work.

Thank you for your input! No idea why I’m having to do my tab triggers this way, but at least they’re working now!

1 Like

#6

And, also, if anyone else if have some issues with typing/navigation in sublime text 3:
I just noticed that my computer keyboard was set to unicode. When I changed it back to US, I not longer had the issues with snippets and also with navigating my code. For example, holding option with my arrow keys was not jumping word to word. Changing my keyboard back to US from unicode resolved both issues.

1 Like

#7

Hi, I’m trying to find the same success you had but I am at a loss.

Using latest Sublime version, Emmet and working with XML files.

When I type anything, then press tab, I automatically get <anything></anything> no matter what I type. That’s great, but when I type the name of my snippet like vnm,tab (or _vnm,tab per your suggestion) all I get is <vnm></vnm>

The only way I can insert snippets is to click on Tools, Snippets and choose the right one. When choosing from the menu they work every time.

Any help on this would be greatly appreciated.

0 Likes

#8

It’s because the tab trigger has to be composed only of character that aren’t match by this settings: word_separators

@greenj Yes, Emmet is really annoying me too these days… Have you looked in the Emmet settings? Maybe remove all your settings? I know there is an other project like this, but only for ST, so it’s going to be more optimized (but I forgot the name, sorry)

0 Likes

#9

It works for me too. Thank you Kiday.

0 Likes