Sublime Forum

Multiple tabTrigger tags in a snippet

#1

I am creating some snippets and I want a few to have multiple tabTriggers. For example, in the following code, I’d like snippet to trigger on create[TAB] and button[TAB]. Is this possible, or is there a better way to do this?

<snippet>
	<content><![CDATA[var ${1:button} = Ti.UI.createButton(${2:\{
	${3:title:"${4:my button}"}
\}});]]></content>
	<tabTrigger>create,button</tabTrigger>
	<scope>source.js</scope>
	<description>Ti.UI.createButton()</description>
</snippet>
2 Likes

#2

This isn’t supported: you’d have to have two snippets with different tab triggers but the same contents

0 Likes

#3

+1

Would be great to have this, if only to be able to trigger snippet for any part of word. In other words, s sw swi swit switc switch would all trigger a switch () {} snippet on tab (or show options if there are other matches).

0 Likes

#4

Did you tried sublime-completion file?
Here is how i did it for css: gist.github.com/1274586

notice things like this:

{ "trigger": "d|dis|display", "contents": "display:${1:block}${2:none}${3:inline-block};$0" },

It’s also an easy way to maintain a large number of snippets for the same language/scope :smiley:

0 Likes

#5

well, i wrote some simple sublime plugin that provides window command to generate snippets for diffrent tab triggers.
https://github.com/mikomize/mtts

0 Likes

#6

Tested and working fine now in ST4.

0 Likes