vim highlight (color) parentheses

6

1

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

ttagy12

Posted 2010-10-30T00:06:07.530

Reputation:

Answers

4

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

Heptite

Posted 2010-10-30T00:06:07.530

Reputation: 16 267

Perfect answer. In my copy I replaced BufRead,BufNewFile with VimEnter and put the hi line in my colors file. Beeyouteefull. – lee8oi – 2018-12-15T21:15:58.273

Maybe I should say, VimEnter,BufWinEnter. That's what finally got it working for me both when I opened vim and when using :e filename. – lee8oi – 2018-12-15T22:58:12.010

4

Rainbow Parenthesis Highlight matching parens in a rainbow of colors

SergioAraujo

Posted 2010-10-30T00:06:07.530

Reputation: 211