Monday, January 2, 2012

Re: Help with VIM syntax region regex please....

On Mon, Jan 2, 2012 at 5:40 AM, wombatvvv <captaineight@gmail.com> wrote:
>
> Hello,
>
> I'm doing something a little complex with my syntax highlighting, and I'm
> having a problem.
>
> I want if-blocks to be highlighted differently. I want the if-block to start
> with the word "if" and end one-space before the { symbol, but ONLY match if
> there is a { symbol. In other words, not to match if the if-statement is a
> one or two-line statement that doesn't use curly braces.

Just curious, which language is this for? C?
So, if I understand correctly,
if (i>0) {
printf("Hello!");
}

...should match and
if (i>0)
printf("Hello");

..should not match?

And when it does match, the "if (i>0)" must get highlighted.


> So far, I have this:
>
> syntax region blockStartLvl1 start=/if/ end=/{/me=e-1
> contains=@blockStartLvl1Contents
>
> Which works fine, as long as the if statement is followed by curly braces.
What is the problem then?

Btw, a perhaps syntax match would be simpler?
syntax match blockStart "\<if\>.*\ze{"

--
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: