[TxMt] Re: Conditional insertion help

guerom00 romain.guerout at stud.unibas.ch
Mon Sep 18 18:26:44 UTC 2006

Allan Odgaard <throw-away-1 at ...> writes:

> On 18/9/2006, at 15:36, guerom00 wrote:
> > [...] What I would like to do is, in the “allocatable” or  
> > “dimension” case, that the caret goes between the braces after I  
> > type in the name. In the snippet definition, that would be to  
> > somehow define a $4 key but I really don't know how to do this...
> This is not possible (but something I would like to allow later).
> The printf snippet in the C bundle tries to fake it by having an  
> extra tab stop, and then conditionally inserts ‘(’ to the left of it,  
> and ‘)’ to the right (well, it actually uses other characters, but in  
> this case it would).
> For an example, switch to C, then type ‘printf’ followed by tab. Now  
> if you delete the %s text, the argument placeholder disappears, and  
> tabbing goes after the ‘)’, if however you keep it, or later write  
> another %-sequences, the argument placeholder appears again, and  
> tabbing goes to right before the ‘)’.

Thanks Allan :-)

I ended up making something like this : 

real*${1:8}${2: a/d}${2/(,a)|(,d)/(?1:llocatable)(?2:imension)/}
${2/,a|(,d)/(?1:\()/}$5${2/,a|(,d)/(?1:\))/} :: ${3:name}

It's not perfect (there are unwanted tab stops) but I still find it
more convenient than putting the caret between the braces
“by hand”.

More information about the textmate mailing list