Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim go to std library method/function definition

I love some of the plugins affiliated with vim and I have installed most of them as git submodules (clang_complete, cvim, fugitive, NerdTree, pathogen, snipMate, supertab, taglist) However there are two basic featured that I cannot get working. i.e.

1) Example -> if I compile the following example

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}

I can not figure out how to jump for example to the function open i.e. “myfile.open” from the std. library. If I go and paste the code to visual studio and click go to definition it is taking me directly to that place. I have read that this could be done with ctags, however I am asking myself if the autocompletion is already working i.e. when I type “myfile.” I see a whole bunch of methods that clang is giving me , so I guess that it should be some other better way to jump to the definition from vim something similar to (ctrl + ]) which should work out of the box.

2) In visual studio/.net whenever I type the dot . I see methods and when I scroll down the method it is supplying short description what is this method doing. Is there a way to enable something similar in vim. As far as I can tell this should be a property of the std library however I can not see any such thing in std.

like image 974
Tito Avatar asked Oct 24 '25 05:10

Tito


1 Answers

You are confusing Vim with an IDE, I think.

You can't expect any IDE feature to be available, at least without some effort, in a (very powerful) text editor.

  1. Vim's equivalent of "Go to declaration", <C-]> or :tag foo<cr> relies on the availabilty of one or more tags generated by exuberant-ctags or some compatible program against your code base and any standard libs. Because Vim doesn't come with such a tags file for (AFAIK) any language, you'll have to generate one by yourself and tell Vim where to find it. There's even a program, hdrtag, specifically written for that, I've never used it, though.

  2. I think I've seen some autocompletion plugins show the signature of the method in the popup menu, some others (PHP, Python) open a small "preview" window. That's as far as you can get. There's also <C-w>} if you have an up to date tags file.

Again: Vim is not an IDE.

like image 92
romainl Avatar answered Oct 26 '25 18:10

romainl