Finding definitions/references to C++ class members in Vim


Question

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();

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.

Also, if I am at a function definition:

Square::rotate()
{
    ...
}

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

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?

1
17
12/2/2009 5:42:50 AM

SrcExpl might be the plugin you needed. Try it.

3
12/4/2009 9:21:11 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon