1

Is there a vim plugin that allows you to place the cursor over a function and have a plugin run a script that searchs a tag or some other entity for where that function is defined. Or perhaps it provides a list of places where that function is defined? Specifically I am looking for a C/C++ based plugin.

Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140

3 Answers3

2

You want ctags, which supports many, many languages beyond C. It will show you the definition of the function or variable under the cursor.

Adam Liss
  • 47,594
  • 12
  • 108
  • 150
  • I have ctags installed. I use it in connection with OmniCppComplete to generate tags for system headers. Is there something specific I am supposed to do with ctags to provide me with the functionality requested above? – Matthew Hoggan Apr 29 '12 at 04:32
  • Did you try a web search for "vim ctags" ? http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks – Adam Liss Apr 29 '12 at 04:35
  • From what i've seen, ctags collects tags, it's a glorified dictionary. If you follow a symbol which has many matches (the different functions with the same name in many different .c files) it will not know which is which and will ask you. Handy, but hardly what the OP asked (i think). – vesperto Mar 30 '17 at 09:48
0

cscope integrates nicely with Vim to do exactly that and more. Where a function is defined, where it is called etc. You may also need a tags with cscope.

simon
  • 1
-1

The vim website hosts a lot of plugins, you might really want to look there. Also, you didn't really specify what languages you wanted this to apply to, so this is a very broad question (hard to find a real answer to this).

An alternative to your question is, instead of putting the lookup capability into vim, why not put in into something else that already has it? Why not eclipse? There's an eclipse plugin called vrapper that gives vim like functionality within eclipse. You can then use eclipse to do the referencing and lookup that you want to do, because it already has this supported for many languages.

Edit: wouldn't this solve it?

I think you wanted to know what it was that you had to do to be able to solve the problem, as though you knew the feature was there but not how to use it. That link explains it. If that is the solution to your problem, please remember to vote & check XD

Community
  • 1
  • 1
Adam Miller
  • 1,756
  • 1
  • 25
  • 44
  • 1
    I dislike IDE's for many reasons. Vim make my life a bit more simple for personal reasons. There are many IDEs out there. I have tried many of them, but keep coming back to vim. Learned to use Vim in highschool and LOVE it. – Matthew Hoggan Apr 29 '12 at 04:36
  • Perhaps because eclipse is a resource hog and can't be used over SSH? – vesperto Mar 30 '17 at 09:49