关闭 C++ 注释中的 vim 语法高亮
Turn off vim syntax highlighting inside C++ comments
我最近下载了 vim 8.0。我不知道是我搞砸了还是默认值改变了,但是在这段代码中...
int foo()
{
// This is a comment containing a "string" and the number 5.
return 42;
}
..."string"
和 5
的颜色不同。它与它们出现在正常代码中时的颜色相同。我以前从没见过。我怎样才能关闭它?
这很难搜索,但答案在 vim 的帮助文件中。它是 vim 附带的 C 和 C++ 代码的语法突出显示功能。来自 :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
c_comment_strings
变量控制注释中字符串、字符和数字的突出显示。它一定是在我的设置中的某处启用的。如果我 :unlet
它,评论将再次以一种颜色突出显示。
好吧,我理解自我回答,但我强烈建议任何认真使用 Vim 作为 C++ 编码工具的人研究 vim color_coded
插件。使用简单的基于 refgexp 的方案无法实现令人满意的着色。虽然并非没有问题,但这个插件(在我看来)最接近于在 Vim.
中进行适当的着色。
我最近下载了 vim 8.0。我不知道是我搞砸了还是默认值改变了,但是在这段代码中...
int foo()
{
// This is a comment containing a "string" and the number 5.
return 42;
}
..."string"
和 5
的颜色不同。它与它们出现在正常代码中时的颜色相同。我以前从没见过。我怎样才能关闭它?
这很难搜索,但答案在 vim 的帮助文件中。它是 vim 附带的 C 和 C++ 代码的语法突出显示功能。来自 :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
c_comment_strings
变量控制注释中字符串、字符和数字的突出显示。它一定是在我的设置中的某处启用的。如果我 :unlet
它,评论将再次以一种颜色突出显示。
好吧,我理解自我回答,但我强烈建议任何认真使用 Vim 作为 C++ 编码工具的人研究 vim color_coded
插件。使用简单的基于 refgexp 的方案无法实现令人满意的着色。虽然并非没有问题,但这个插件(在我看来)最接近于在 Vim.