I am trying to make a snippet for easy writing of Effective Uniform Annual Worth calculations which look something like this: EUAW = (Yearly Benefit + Salvage Value*[A/F, $5%, $6]) - (Yearly Cost + Initial Cost*[A/P, $10%, $11]) = [same thing but with [] expressions replaced by table lookups i do by hand]
This is the snippet I've crafted for this (and to learn how to use conditionals in snippets in general):
EUAW($1) = (${2:Yearly Benefit}${3: + ${4:Salvage Value}[A/F, $5%, $6]}) - (${7:Yearly Cost}${8: + ${9:Initial Cost}[A/P, $10%, $11]}) = ${14:($2${4/$|(.+)/(?1: + $1*0.)/}$12) - ($7${9/$|(.+)/(?1: + $1*0.)/}$13)}
That fills in everything, with appropriate mirroring, with one exception. I want the text that's inserted if Salvage Value or Initial Cost are not removed to include a tab stop. Thus I want the last line to look, I think, like:
= ${14:($2${4/$|(.+)/(?1: + $1*0.${12:Table Lookup Value})/}) - ($7${9/$|(.+)/(?1: + $1*0.${13: Table Lookup Value})/})}
So that way if the salvage value/initial cost fields are removed in the first part of the equation, the tab stop won't be there, but otherwise it will so I can fill in the table lookup value. However, I've tried about a dozen things and I can't get it to put that tab stop there. I understand that $12 in that context would refer to the regex subexpression 12, but I have tried escaping all sorts of character combinations to prevent that to no avail.
If someone could please tell me how to insert those conditional tab stops in there, I would be most appreciative.
Thanks!
On 7 May 2008, at 10:14, Quine wrote:
[...] I want the text that's inserted if Salvage Value or Initial Cost are not removed to include a tab stop.
A snippet is parsed (for tab stops) when it is inserted.
Adding tab stops to it after that, is presently impossible.
Some snippets (like NSLog in the Objective-C bundle) fakes it by transforming stuff around the existing placeholders.
ah ok. Thanks Allan! Now I can add 'great developer support' to the list of reasons for my friends to buy textmate (I'll get them all one day...one day). :)
On Sat, May 10, 2008 at 6:56 AM, Allan Odgaard throw-away-2@macromates.com wrote:
On 7 May 2008, at 10:14, Quine wrote:
[...] I want the text that's inserted if Salvage Value or Initial Cost are not removed to include a tab stop.
A snippet is parsed (for tab stops) when it is inserted.
Adding tab stops to it after that, is presently impossible.
Some snippets (like NSLog in the Objective-C bundle) fakes it by transforming stuff around the existing placeholders.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate