пятница, 19 октября 2012 г., 13:32:19 UTC+4 пользователь Sektor van Skijlen 
написал:
> Hello,
> 
> I would like to use 'syntax region', where I have a defined start and 
> possible end of region, BUT: after the pattern considered as start it may 
> happen that there is a pattern that should cause the whole region match to be 
> cancelled. It's not something like for 'skip' because it still makes the 
> region to be matched.
> 
> In other words: my region starts from found A letter and ends with Z letter, 
> but can't contain Q letter, so:
> 
> A T W Z E
> 
> makes the region to be matched since the first letter to the last but one. 
> But here:
> 
> T A Q E Z
> 
> despite matching start with A, there is no region to be matched in this 
> sequence because he Q letter causes the matching to be cancelled.
> 
> How to do something like that in vim syntax definition?

In vim regular

    syntax match {group} /\vA[^Q]{-}Z/
can contain syntax elements just like ":syntax region" (and, I believe, but 
have not tried, ":syn keyword"). So, in your example both the above will work. 
With using "\_[^Q]" it will even work for multi-line matches (use 
"\v%(%(Q)@!.){-}" if "Q" is actually a complex pattern). If you are using 
":syntax region" because of nesting possibility you may try to use something 
like "start=/\vA%(%(%(Z)@!\_.){-}Q\_.{-}Z)@!/". Both solutions imply 
performance penalty, second one is more huge (while trying to test this on 
nested if conditions I got "E363: pattern uses more memory than 
'maxmempattern'", increasing it to 200000 has shown that it is working). Any 
regex solution I can imagine won't disable the match in nested regions without 
retreating to handling a number of specific cases:

("<" stands for "A", ">" for "Z" and "X" for "Q")
Text:          < < < > > < < X > > >
Nesting level: 112233322111111111111

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui