Nicodoki
Nicodoki

Reputation: 11

syn match in vimrc but highlight not ok

I have a vimrc file

" activates filetype detection
filetype plugin indent on

" activates syntax highlighting among other things
syntax on
set autoindent
colorscheme default
highlight Comment ctermfg=DarkGreen
    
syntax match dollar "/\$\w*"
highlight dollar ctermfg=magenta

And i want all words with a $ in magenta... But when I open a file, all words with $ are in yellow... And when i try to test the regex with just :/\$\w*, all $word are selected... So I don't understand why highlighting is not OK...

Upvotes: 1

Views: 289

Answers (1)

romainl
romainl

Reputation: 196751

In:

:syntax match {group-name} {pattern}

<pattern> is a pattern, not a search command, so you should drop the / from:

syntax match dollar "/\$\w*"

in order to get:

syntax match dollar "\$\w*"

which works as expected:

enter image description here

Upvotes: 1

Related Questions