user1002430
user1002430

Reputation:

How to add extra syntax highlight rule to existing Vim syntax highlighting script?

I have a syntax highlighting script that is pretty good except I'd like to enhance it without modifying the original file. In particular, it defines an Identifier highlight group name:

:hi Identifier
Identifier     xxx term=underline ctermfg=208 guifg=#FD971F

I'd like to have all words that start with a capital letter ([A-Z]) be highlighted by this. What do I have to add to my .vimrc to get this effect?

Upvotes: 1

Views: 492

Answers (2)

Vitor
Vitor

Reputation: 1976

For more permanent scenarios I prefer to use the syntax commands instead of match, as suggested by @ryuichiro.

Adding something like the following to your vimrc will achieve what you ask for:

:au FileType * syntax match Identifier /\<[A-Z].*\>/

For more information check the following help page:

:help syntax.txt

Upvotes: 4

ryuichiro
ryuichiro

Reputation: 3865

matchadd should do the trick

:au BufWinEnter * let w:m1=matchadd('Identifier', '\<[A-Z].\{-}\>', -1)

Upvotes: 0

Related Questions