Sublime Forum

Snippet with prefilled completion list

#1

Hello,

I am trying to create a snippet where one of the tab completion stops has pre-filled a static list of available options.

E.g.

<snippet> <content><![CDATA[<argument name="$1" type="${2:type1|type2|type3}">]]></content> <tabTrigger>arg</tabTrigger> </snippet>
I would want it to output the argument tag, with the selection at $1 (which it does) and when pressing tab, go over to the next - $2 and instead of it saying type1|type2 etc. If it could be prefilled with the first value (type1) and automaticly open a dropdown with all the possible values (like autocompletion does). So when coming to the type attribute, I can use the arrow keys to choose which type the argument should be.

Is this possible?

0 Likes

#2

It is possible using some python instead of a regular snippet. I wouldn’t know how to do it though…

You should be able to use regex to achieve something closer to that than using plain snippets too. Check the techniques from Andy Gibson in this post. It’s not exactly what you want… but maybe will give you some ideas to solve your problem faster.

0 Likes

#3

Thanks for leading me in the right direction, however I am not that good with these configurations of ST - I have only tried a few simple snippets, and I couldn’t implement the techniques from Andy to what I wanted. I’ll live without for now, and maybe try again if I stumble upon anyone having done similar to this.

But thanks again :smile:

0 Likes