[TxMt] Re: Conditional insertion with nested placeholder.
Matt Foster
matt.p.foster at gmail.com
Sun Nov 16 14:32:21 UTC 2008
On Sun, Nov 16, 2008 at 10:53 AM, Allan Odgaard
<mailinglist at textmate.org> wrote:
> On 12 Nov 2008, at 10:28, Matt Foster wrote:
>
>> [...]
>> and what I'd like to have is something more like this:
>> for [${1:n} ${2:=} ${2/(in)|(.+)/(?1:"$3":$3\:$4)/}] $0
>>
>> The conditional expansion seems to work ok, but unfortunately the
>> placeholders inside it don't appear.
>
> You can't generate new placeholders via mirrors.
>
> We fake it in a few snippets by having all the placeholders and then
> use transformations to make it appear as if they are moving.
>
> So something like this:
>
> for [${1:n} ${2:=} ${2/(in)|.+/(?1:")/}$3${2/(in)|.+/(?1:":\:)/}$4]
>
> So incase of 'in' you get an extra tab stop after ", but otherwise it
> does what you want. You can probably improve the behavior by rewriting
> the latter transformation into two transformations, one that inserts
> the : and the other which inserts the ", then place $4 before the one
> that inserts ", that way, when the loop uses 'in' it'll have $4
> immidiately after $3 (no character inbetween) and TextMate _should_
> skip it when you tab away from $3 (making $4 appear invisible).
That's excellent, thanks.
--
Matt Foster | http://hackerific.net
More information about the textmate
mailing list