Vim - How to highlight part of a template

I want to highlight an object in Vim C #.

I do the following in cs.vim:

syn match csObject  "[A-Z][_a-zA-Z0-9]*\.[A-Z]"

And highlight it in my color theme

hi csObject     guifg=#ff0000

However, he also draws. and the first letter from the next "word".

enter image description here

How to highlight only the match before the point?

EDIT Thanks to @romainl's answer, I found that it \zssets the beginning of the match, and \zasets the end of the match.

This allowed me to execute the match correctly:

syn match csObject         "[ \t\(\!]\zs[A-Z][_a-zA-Z0-9]\{-}\ze\.[A-Z]"
+4
source share
1 answer

Solving your problem requires only one small modification of your regular expression.

Application, . . , \ze, "" :

syn match csObject "[A-Z][_a-zA-Z0-9]*\ze\.[A-Z]"

, \{-} *.

+4

Source: https://habr.com/ru/post/1607141/


All Articles