#StackBounty: #syntax-highlighting Syntax Highlighting a region inside the start match of another region

Bounty: 100

I have two syntax region defined as follows:

syntax region xBCD start="b" end="d"
hi def link xBCD Todo

syntax region xBlock start="z(abcde)zs::" end=";"
hi def link xBlock Comment

and a text file like this:

abcde::test;

I.e, I have is a syntax region that I’d like to define within the start match of another region.

When I use these regions, then only the xBCD region is highlighted.


If I try to defined xBCD as contained in xBlock, like this:

syntax region xBCD start="b" end="d" contained
hi def link xBCD Todo

syntax region xBlock start="z(abcde)zs::" end=";" contains=xBCD
hi def link xBlock Comment

then I get the opposite effect; everything after start is highlighted as xBlock, but bcd is not highlighted as xBCD.

Is there some way to define and highlight other regions within the un-highlighted parts of a broader region’s start match?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.