I wrote a rather simple syntax file, but digits in identifiers get colored:

syn match xNumber '\d\+'

In i1 the 1 gets the "numbers" color.

Maybe identifiers need to be matched with higher priority? Or perhaps the pattern for number needs anchors, like a word beginning/end. I tried \b and \B, but then numbers were not highlighted anymore.


1 Answer 1


Vim uses \< and \> to search for word beginning/end instead of \b:

syntax match xNumber /\<\d\+\>/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.