Vim region with keywords in syntax patterns

2

I need to create a custom vim region with determines classes and structs. The code, for example,

syn region myCxxClass start="\(class\|struct\)\_[ \t]\+" end="}[^;]*;" transparent

The patterns for start and end probably will be changed, but the problem is that this kind of region does not work, because class and struct are keywords.

How to work around this issue?

user14416

Posted 2013-11-14T18:59:31.187

Reputation: 298

Answers

3

You're right about the keyword match preventing a match of your new region. To workaround, you need to redefine the keywords to be contained in your region:

syn clear cStructure
syn clear cppStructure
syn keyword cStructure struct contained
syn keyword cppStructure class contained
syn region myCxxClass start="\(class\|struct\)\_[ \t]\+" end="}[^;]*;" contains=cStructure,cppStructure

Ingo Karkat

Posted 2013-11-14T18:59:31.187

Reputation: 19 513