Wednesday, December 11, 2013

Re: Syntax: group which can be contained or uncontained

> I'm trying to write my own syntax file for a language where there are
> a lot of groups of the form
>
> :syn match langSomeGrp /^\s*KeyWord.*/
>
> The problem is that there are also end-of-line comments
> :syn match langComment /--.*/
>
> which can either stand on a line of its own OR be contained in a
> group like the above. How do I express that? Is it OK to have a
> contains=grpB in the declaration of a match grpA without a
> containedin=grpA in the declaration of match grpB?

Yes. "contains=X" and "containedin=Y" are two ways to declare the same thing:
a group is contained in another one. So

syn match Foo /whatever/ contains=Bar
syn match Bar /xyz/

and

syn match Foo /whatever/
syn match Bar /xyz/ containedin=Foo

are equivalent. You still have to add "contained" to Bar in both cases if
necessary, but since your comment can be on a line of its own it is not always
contained.

Best,
Paul

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: