[TxMt] match and look ahead?

Allan Odgaard allan at macromates.com
Mon Sep 5 20:16:21 UTC 2005


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"; };
                 };
             }
         );
     },




More information about the textmate mailing list