Hi all,
I made some snippets using conditional insertions for my declarations in Fortran. For example, I have this one :
real*${1:8}${2: a/d}${2/(,a)|(,d)/(?1:llocatable) (?2:imension)/}${2/,a|(,d)/(?1:())/} :: ${3:name}${2/,d|(,a)/(?1:())/} $0
which does that :
http://guerom00.free.fr/clutter/Cond_insert.mov
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...
Any help is much appreciated :-)
PS : Once again, due to my poor knowledge of RegExp, if anyone has some suggestions/improvements for this snippet, he is quite welcome :-D
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 ‘)’.
Allan Odgaard <throw-away-1@...> 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} ${2/,d|(,a)/(?1:()/}$4${2/,d|(,a)/(?1:))/} $0
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”.