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?
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.
Well, I understand the self-answering, but I strongly suggest for anybody being serious about using Vim as a C++ coding tool to look into vim color_coded
plugin. There is no way one can achieve satisfactory colorizing with simple refgexp-based scheme. While not without the issues, this plugin (in my view) is as closest as it gets to doing proper colorizing in Vim.
If I understand it correctly, you only want to turn off syntax highlighting.
:syntax disable
If you are non-root and set nocompatible, you can comment it in the last line (see 'h:modeline').
// vi:syntax disable:
Everytime you open it as non-root user, the command will take effect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.