在Vim中查找C ++类成员的定义/引用 [英] Finding definitions/references to C++ class members in Vim

查看:699
本文介绍了在Vim中查找C ++类成员的定义/引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Vim作为一个C ++项目,我已经开始工作,我花了很多时间浏览现有的代码,以获得它的悬念。为了使浏览更容易,我在Vim中设置了ctags和cscope来跳转到定义和查找引用。

I'm using Vim for a C++ project that I've started working on and I've been spending a lot of time lately browsing through the existing code to get a hang of it. To make the browsing easier, I've setup ctags and cscope in Vim to jump to definitions and find references.

但是,我发现他们都不够智能知道成员变量/函数属于哪个类。例如:

However, I find that neither of them are intelligent enough to know which class a member variable/function belongs to. For example:

class Square;
...

Square a;
...
a.rotate();

试图找到 rotate()的定义将调用其他类的成员函数,如三角形。我在Vim中使用 g] 打开一个匹配的标签列表,幸运的是ctags列出了每个条目的关联类。但是,当有200个具有相同成员函数的类时,捕获正确的标签可能是令人厌烦的。

Attempting to find the definition of rotate() will bring up member functions from other classes too, like Triangle. I use g] in Vim to bring up a list of matching tags and fortunately ctags lists the associated class for each entry. However, when there are 200 classes with the same member function, it can be tiresome to hunt down the correct tag.

此外,如果我在一个函数定义: / p>

Also, if I am at a function definition:

Square::rotate()
{
    ...
}

尝试使用cscope来查找对 rotate()的所有调用

Attempting to find all calls to rotate() using cscope brings up calls to Triangle's and other classes' rotate functions.

因为这个原因,我发现自己每次都跳到 Visual Slickedit 成员函数或成员变量的定义或引用。

Because of this, I find myself jumping to Visual Slickedit every now and then to find the definition or reference to a member function or member variable. Is there any way I can accomplish this in good old Vim?

推荐答案

SrcExpl 可能是您需要的插件。尝试一下。

SrcExpl might be the plugin you needed. Try it.

这篇关于在Vim中查找C ++类成员的定义/引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆