Friday, December 17, 2010

Re: syn match works but not syn region?

On Dec 16, 1:21 pm, AK <andrei....@gmail.com> wrote:
> On 12/16/2010 02:08 PM, Ben Fritz wrote:
>
>
> >> syn region hl1 start=/(/ end=/)/
> >> hi def hl1 guifg=#57a guibg=#333
>
> >> (test) is not highlighted at all.
>
>
> syn match potlTab0 /^ [^\t].*/
> hi def potlTab0 ctermfg=1 cterm=NONE guifg=brown
>

Your syn match command either needs a contains=hl1, or your syn region
command needs a containedin=potltab0.

Your syn match will match "a space at the beginning of the line,
followed by anything not a tab, followed by any number of anything".
This means that on lines where (test) is not at the very beginning of
the line, the match will apply first, taking precedence. Syntax rules
do not allow matches of other rules within them unless you tell them
to.

With your two sytax rules I get the 2nd line to match your region, but
not the first:

...(test)
(test)

If I add a containedin=potlTab0 to the syn region, the (test) on both
lines is highlighted.

--
You received this message from the "vim_use" 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

No comments: