3

I wanted a cross reference navigation similar to Source Insight. Lets take simple example:

classA::MethodB() 
{
   ...
   m_variable = value;
}

In this example if I use Ctags / Cscope, then when I try to find m_variable, it will show me all the available m_variable. I need to go through each and then find which one is required.

Where as in Source Insight, it clearly gives me the Class delectation.

Is there any such Cross ref tools available for Vim?

hari
  • 1,419
  • 4
  • 19
  • 30

2 Answers2

2

Vim is not an IDE, it's a text editor.

You can't reasonably expect it to understand your code as well or as deeply as an IDE.

IDEs typically keep a dynamic internal representation of your code which makes them able to track declaration and usage even when you have dozens of methods or variables with the same name. Vim, like most text editors, is not able to do that on its own: it must rely on external tools for indexing/navigating through your code. Now, because of architectural constraints, Vim is incapable of running any background process which is the absolute prerequisite for a real "code intelligence" to be added to Vim.

Given all that, you are left with code indexers like ctags, cscope or GLOBAL. These tools do their best trying to give you accurate results but they are not as smart and as specific as the tools used in IDEs.

To compensate, Vim has a bunch of different commands like :tselect or g] which open a list of possible tags to chose from. Read :h tags, :h ctags and :h cscope for how to deal with those limitations.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Yes I completely agree that VIM is not an IDE. What I was looking for was if there is any tool which is better than ctags, which is integrated with VIM. Currently I am listing all the matches and choosing one. But when it comes to go around big source code like Qt, I find it difficult as some times it lists more than 100 occurrences. – hari Apr 16 '13 at 10:43
  • I'm glad we agree on that point. Unfortunately, there's not much choice besides ctags, cscope and gnu global. – romainl Apr 16 '13 at 11:28
0

I've not tried this myself. But sounds like eclim is what you're looking for. http://eclim.org/

It provides eclipse features to be accessible from Vim, including code searching and auto-completion.

ruben2020
  • 1,549
  • 14
  • 24