Sublime Forum

Snippets: select from alternatives?


Many years ago I moved from Kate and dearly missed the ability to select among alternatives (e.g,. class names, standard resolutions, etc.) in ST3. Now that I’m ST4, I wonder if there’s any way to achieve this?



Not sure what you mean.

In ST3 you were able to type a word and than hit tab to cycle through snippets. This feature may have conflicted with other kinds of completions if auto_complete_commit_on_tab was set.

Hence snippets and other completions are treated more or less equally in ST4. All snippets whose tabTrigger matches ST’s search algorithm are provided in the auto completion panel in ST4. Depending on syntax and available completions/snippets ST just may sometimes not provide expected snippets for yet unknown reasons.



See the documentation for VSC’s placeholder choice, for example.

Placeholders can have choices as values. The syntax is a comma-separated enumeration of values, enclosed with the pipe-character, for example ${1|one,two,three|} . When the snippet is inserted and the placeholder selected, choices will prompt the user to pick one of the values.

Kate and other editors often have something like this. So I could select from preconfigured options, like common resolutions.

I wonder if ST4 supports something like this, or whether it has its own way? (For example, nesting snippets?)

Right now, I have an ugly details that reminds me some of the values $2 can take:

{ "trigger": "rfr", "contents": "[$1]{.fragment .$2}", "annotation": "fragment style", "details": "grow shrink strike [semi-]fade-{out {up down left right} in-then-out in-then-semi-out} highlight-{red green blue} highlight-current-{red green blue}", "kind": "markup", },
to create

[Amazing!]{.fragment .grow}.



It’s not pretty, but I can kind of achieve this with a snippet and set of completions.

<description>Inline attributes for RevealJS fragments</description>
<!-- see markdown completions for rfd -->
<content><![CDATA[[$SELECTION]{.fragment .${1:rfd}$0]]></content> 

{"trigger": "rfd", "contents": "fade-out}", "kind": "markup", "annotation": "fade-out"},
{"trigger": "rfd", "contents": "fade-up}", "kind": "markup", "annotation": "fade-up"},
{"trigger": "rfd", "contents": "fade-down}", "kind": "markup", "annotation": "fade-down"},
{"trigger": "rfd", "contents": "fade-left}", "kind": "markup", "annotation": "fade-left"},
{"trigger": "rfd", "contents": "fade-right}", "kind": "markup", "annotation": "fade-right"},
{"trigger": "rfd", "contents": "fade-in-then-out}", "kind": "markup", "annotation": "fade-in-then-out"},
{"trigger": "rfd", "contents": "fade-in-then-semi-out}", "kind": "markup", "annotation": "fade-in-then-semi-out"},
{"trigger": "rfd", "contents": "grow}", "kind": "markup", "annotation": "grow"},
{"trigger": "rfd", "contents": "semi-fade-out}", "kind": "markup", "annotation": "semi-fade-out"},
{"trigger": "rfd", "contents": "shrink}", "kind": "markup", "annotation": "shrink"},
{"trigger": "rfd", "contents": "strike}", "kind": "markup", "annotation": "strike"},
{"trigger": "rfd", "contents": "highlight-red}", "kind": "markup", "annotation": "highlight-red"},
{"trigger": "rfd", "contents": "highlight-green}", "kind": "markup", "annotation": "highlight-green"},
{"trigger": "rfd", "contents": "highlight-blue}", "kind": "markup", "annotation": "highlight-blue"},
{"trigger": "rfd", "contents": "highlight-current-red}", "kind": "markup", "annotation": "highlight-current-red"},
{"trigger": "rfd", "contents": "highlight-current-green}", "kind": "markup", "annotation": "highlight-current-green"},
{"trigger": "rfd", "contents": "highlight-current-blue}", "kind": "markup", "annotation": "highlight-current-blue"},



I did look for an issue, thanks for this pointer.