Tito
Tito

Reputation: 2300

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.

Upvotes: 4

Views: 2976

Answers (2)

romainl
romainl

Reputation: 196576

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.

Upvotes: 4

Johan
Johan

Reputation: 20763

Make sure that ctags can find the source code that is in the std lib when you generate the index and you should be fine.

By default those index tools only adds code in the current dir (and its subfolders), so you need to manually tell him where that code is installed on your system.

Upvotes: 0

Related Questions