vim c++ syntax contained region

时间:2017-10-12 09:55:00

标签: vim vim-syntax-highlighting

I define four key words and two regions in vim scripts

syn keyword KeywordA A nextgroup=rangeA skipwhite skipnl skipempty
syn keyword KeywordB B contained containedin=rangeA nextgroup=rangeB skipwhite skipnl skipempty
syn keyword KeywordC C contained containedin=rangeA
syn keyword KeywordD D contained containedin=rangeB

syn region rangeA start=+{+ end=+}+ contained transparent
syn region rangeB start=+{+ end=+}+ contained transparent

hi KeywordA ctermfg=blue
hi KeywordB ctermfg=green
hi KeywordC ctermfg=cyan
hi KeywordD ctermfg=red

The keywords A and B has two corresponding regions.

When the file is saved as .cpp or .c

The highlighting result is like this:

highlighting

Actually, the D is in rangeB, but D is not highlighted.

However, if I change the file extension to .t

the result is what I expect:

enter image description here

Is there any solution that I can highlight C and D in rangeB in a cpp file? (Since C in rangeB is also in rangeA)

Thanks in advance.

0 个答案:

没有答案