Lets say I have a line like the following in a vim syntax file:
syntax match Emphasis "\v\s+_\zs[^_\n]+\ze_\s+"
In this line I'd like to create multiple capture groups:
- the first underscore as "EmphasisStartMarker"
- the content between the two underscores as "Emphasis"
- the second underscore as "EmphasisEndMarker"
I know that \zs
starts matching and \ze
ends it. So I tried:
syntax match EmphasisStartMarker "\v\s+\zs_\ze[^_\n]+_\s+"
And
syntax match EmphasisEndMarker "\v\s+_[^_\n]+\zs_\ze\s+"
However, this does not work, probably because somehow the start marker already consumes the content and the end marker text.
I could not find a description for matching capture groups and how to write that in a syntax file. I'd like to have something like:
syntax match "\v\s+(_)([^_\n]+)(_)\s+"
1=EmphasisStartMarker
2=Emphasis
3=EmphasisEndMarker
I know there is something with region
and start
and end
, but that won't be useful if I have more than 3 capturing groups.
What is VIM's syntax for this? Is it possible? If not, how to workaround?