In general, you can use only one way to highlight syntax in one place. Therefore, to use C-like syntax as an example, if you define a region that should start with the opening bracket '{' and end with a closing bracket '}', the syntax highlighting for that region will be the same.
contains= allows you to configure other syntax highlighting groups that should be contained in the external group. To follow the previous example, you can select an int even if it is in an external region. Then you might have something like:
syn keyword Keyword int syn region BraceBlock start='{' end='}' contains=Keyword
Quite often, you need to add items later in your keyword list. There are several ways to do this. First, you can use contains=ALL or contains=ALLBUT,Error so that everything is in the region. Secondly, you can use containedin to insert something into the contents of another area:
syn region BraceBlock start='{' end='}' syn keyword Keyword int containedin=BraceBlock
Thirdly, you can define everything that is “contained” as valid in this group:
syn region BraceBlock start='{' end='}' contains=CONTAINED syn keyword Keyword int contained
Finally, you can use clusters that make it easy to decide what happens:
syn region BraceBlock start='{' end='}' contains=@MyCluster syn keyword Keyword int syn cluster MyCluster contains=Keyword syn keyword Conditional if else syn cluster MyCluster add=Conditional " Now conditionals and keywords can appear in a BraceBlock
Not knowing exactly what you want to understand, I'm not sure what else to say - what are you trying to achieve and what causes problems?
DrAl Nov 30 '09 at 11:03 2009-11-30 11:03
source share