Finding definitions/references to C++ class members in Vim
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 t开发者_运维知识库here any way I can accomplish this in good old Vim?
SrcExpl might be the plugin you needed. Try it.
I've looked for better solutions than cscope in the past, but never found something. In the end perhaps cscope lack of intelligence isn't really that much of a bother.
The problem is that there is no powerful and open intellisense library on the market. Perhaps CodeInsight.
Seems like this would be a good candidate http://vim.wikia.com/wiki/C%2B%2B_code_completion. I had some good luck with it doing similar things in Java. Not entirely sure it gets you everything you're trying to do though.
You could try taglist plugin, though it still to some extend suffers the same problem as the built-in ctag support. It works the same sort of way that SrcExpl does.
精彩评论