vim highlight (color) parentheses

I have tried to put the following in my .vimrc file:

syn match parens /[(){}]/
hi parens ctermfg=red

to permanently color brackets, parentheses, braces etc, however it doesnt work. If I do it inline inside vim it does work.

Any ideas why?

Thanks


Solution 1:

Because all syntax highlighting is local to the buffer that is active when the syntax items are defined. Try something like this:

autocmd BufRead,BufNewFile * syn match parens /[(){}]/ | hi parens ctermfg=red

Solution 2:

Rainbow Parenthesis Highlight matching parens in a rainbow of colors