I just switched to iTerm2 on macOS and found some of its options go to Vim as well. That's the case for fonts, I was able to select a Vim font that I like from iTerm options.

It seems iTerm color options also apply to Vim highligh. But in this case highlight situation is not good enogh for my taste. So I tried to change:

:hi Comment ctermfg=gray

Changes font color of comments.

I would like to change =, ::, +, - color, I think these are Operators, so I tried:

:hi Operator ctermfg=blue

But it seems nothing changes. How should I do that?

If it matters I'm playing with .cpp/.h files.

1 Answer 1


It indeed looks like cppOperator links to Operator which links to Statement (-> :hi cppOperator), but I've never seen these operators displayed differently...

It's just for the keywords. See syn list cppOperator. I guess you'd have to add these symbols to the cppOperator list. You may need a syn match that takes care of not overlapping with cFloat and some other syntax groups. Indeed, if we look closely at $VIMRUNTIME/syntax/c.vim we see that cFloat can match + or - in the possible patterns.

Let's experiment on

42 + 12;
42 foobar 12;
  1. :syn keyword cOperator + has no visible effect
  2. yet :syn keyword cOperator foobar has a visible effect => syn keyword is not what we're looking for
  3. however :syn match cOperator "+" has the effect we are looking for: now we have a match for +
  4. better yet, we can have :syn match cOperator "[+/*%^&|<>-]", we can observe:

    • there is no interaction with cFloat: check 12 * 1e-1 -- my fears were unfounded
    • pointers and addresses will also be highlighted -- excluding these cases will require more tweaking.

      void * p = &var;
      12 * *p;


  • Before the modification, the operators belonged to cBlock, now they belong to cOperator. We can change the highlighting of Operator, it will now also affect these operators.
  • Put the new :syn... commands into {rtp}/syntax/c/c-highlight-operator.vim for instance. -- by {rtp}, understand any path in your 'rtp' option.
  • Why specifically mention cFloat?
    – KcFnMi
    Commented Aug 7, 2018 at 12:09
  • If you look at cFloat pattern, you'll see that it can match + and - signs. Commented Aug 7, 2018 at 12:11
  • May I ask how to do that? I mean the syn match.
    – KcFnMi
    Commented Aug 7, 2018 at 20:31
  • I tried hi cFloat ctermfg=blue but no changes so far, I was expecting something if it includes + and -. I guess I'm missing something
    – KcFnMi
    Commented Aug 8, 2018 at 1:24
  • I've edited my answer Commented Aug 8, 2018 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.