Search code examples
vimsyntax-highlightingparenthesescurly-braces

How to set curly braces'/parentheses'/square brackets'/arithmetic operators' syntax highlight color in VIM?


How do I highlight operators/parentheses/brackets/etc. in VIM? I'm not interested in coloring matching or unmatching parentheses/brackets.

I've tried ":hi cBracket/whatnot guifg=something" and ":hi Operator/cOperator guifg=something" but these don't seem to affect anything.


Solution

  • There are two parts to Vim syntax coloring: the syn command and the hi command.

    As far as I understand, you use syn to define syntax. For example:

    syn match parens /[(){}]/
    

    Then you use hi to tell Vim how to highlight parens:

    hi parens ctermfg=red