[TxMt] Placeholders within transformations in snippets

Nigel Chapman nigel at macavon.co.uk
Mon Dec 1 18:47:37 UTC 2014


I have a suspicion this can’t be done, but perhaps I’ve just missed something.

I’m trying to write a snippet to insert operator declarations in Swift. The basic syntax is

(postfix|infix|prefix) operator <name> { }

But, if we are declaring an infix operator, we may also add

precedence <level>
associativity (left|right|none)

inside the curly brackets.

This is what I’ve got, based on the example at the end of section 6.8 in the manual.

${1|infix,prefix,postfix|} operator ${2:name} { ${1/(infix)|prefix|postfix/${1:+\n\tassociativity ${3|left,right, none|}\n\tprecedence${4:level}\n}/}}

As you can see if you can read that lot, I’m trying to use $3 and $4 as placeholders within the conditional insertion.

It doesn’t work of course. I assume this is because in that context $3 and $4 refer to captures from the regular expression. Is that so? Is there any way round this?

Thanks to anyone who can help

Nigel Chapman



More information about the textmate mailing list