Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off vim syntax highlighting inside C++ comments

I recently downloaded vim 8.0. I don't know if I messed something up or a default changed, but in this code...

int foo()
{
    // This is a comment containing a "string" and the number 5.
    return 42;
}

...the "string" and 5 are in a different color. It's the same color as when they appear in normal code. I've never seen that before. How can I turn it off?

like image 211
Michael Kristofik Avatar asked Dec 02 '16 20:12

Michael Kristofik


People also ask

How do I get rid of red highlight in vim?

If you want to avoid this in an apache . conf file like I did, you can add it to the end, like "# vim: nospell". Or, you could add words to spelling dictionary. I have to do set nospell , every time that red happens!

How do I turn on syntax highlighting in Vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.


1 Answers

This was unusually hard to search for, but the answer is in vim's help files. It's a feature of the syntax highlighting for C and C++ code that ships with vim. From :h ft-c-syntax:

A few things in C highlighting are optional. To enable them assign any value to the respective variable. Example:
:let c_comment_strings = 1
To disable them use ":unlet". Example:
:unlet c_comment_strings

The c_comment_strings variable controls the highlighting of strings, characters, and numbers inside of comments. It must have been enabled somewhere in my setup. If I :unlet it, comments are all highlighted in one color again.

like image 62
Michael Kristofik Avatar answered Sep 27 '22 00:09

Michael Kristofik