[TxMt] match and look ahead?
Gerd Knops
gerti at bitart.com
Mon Sep 5 22:32:27 UTC 2005
On Mon, Sep 5, at 3:16 PM, Allan Odgaard wrote:
> On 05/09/2005, at 21.26, Gerd Knops wrote:
>
>
>> To make it easier to visually parse blocks, I am trying to write a
>> pattern that matches on 'even tabs' and give them a light gray
>> background.
>>
>> I tried something like
>> match= "^(?=\\t)\\t";
>> but that doesn't seem to work. Is look ahead not possible in
>> pattern matches?
>>
>
> It is, but that pattern would match the first tab on a line.
>
> To markup leading odd/even tabs, you could use a rule like this:
>
> { name = "meta.leading-tabs";
> begin = "^(?=\\t)"; end = "(?=[^\\t])";
> patterns = (
> { match = "(\\t)(\\t)?";
> captures = {
> 1 = { name = "meta.odd-tab"; };
> 2 = { name = "meta.even-tab"; };
> };
> }
> );
> },
>
Fantastic! Works great and makes complex code much more readable. I
use a 95% white background for the even tabs. It is subtle but
extremely helpful. May I recommend that being added to all languages
where it makes sense?
Gerd
More information about the textmate
mailing list