班级在 Vim 中高亮显示函数名称

2023-07-01C/C++开发问题
3

本文介绍了班级在 Vim 中高亮显示函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在对它的模态输入上瘾之后,我最近刚刚从 Textmate 设置了我的 Vim 环境.

I just recently set up my Vim environment from Textmate, after becoming addicted to its modal input.

然而,语法高亮在 Vim 中似乎没有那么漂亮.我用 C++ 编写代码,由于无法突出显示函数调用和类名,因此代码更难阅读.我玩了一会儿配色方案,但找不到任何与类名"或函数名"相对应的字段.

However, syntax highlighting seems to be not so beautiful in Vim. I code in C++ and since the function call and class names can't be highlighted, the code is more difficult to read. I played with color scheme for a bit, but couldn't find any field that corresponded to "class name" or "function name".

在下图中,注意 DroughtLayer::*.size() 在 MacVim 的右侧没有突出显示.

In the picture below, notice how DroughtLayer:: and *.size() is not highlighted on the right in MacVim.


(来源:ivzhao.com)

任何想法如何解决这个问题?这真的让我很恼火,因为我是一个对视觉非常敏感的人.

Any ideas how to solve this? It really annoys me as I am so much a visual-sensitive guy.

推荐答案

有趣的是,VIM 中的语法高亮器不支持将语法应用于标识符或函数名称——至少不支持 C 和 C++ 的语法高亮器.所以,即使你这样做:

Interestingly, the syntax highlighters in VIM don't support applying a syntax to identifiers or function names - at least not the syntax highlighters for C and C++. So, even if you do:

:hi Function guifg=red

:hi Identifier guifg=red

它没有给这些颜色.我似乎只是这些语言的关键字和常量.

it doesn't give these a color. I just seems to be not much more than keywords and constants for these languages.

这里,有人开始扩展 cpp 语法文件以支持方法名称.我想这是一个开始.http://vim.wikia.com/wiki/Highlighting_of_method_names_in_the_definition

Here, someone has started extending the cpp syntax file to support method names. It's a start I guess. http://vim.wikia.com/wiki/Highlighting_of_method_names_in_the_definition

这篇关于班级在 Vim 中高亮显示函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6