4

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.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Tito
  • 2,234
  • 6
  • 31
  • 65

2 Answers2

4

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.

Grimeh
  • 161
  • 1
  • 12
romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thank you for your replay, Let me rephrase the question. How it is possible that clang_autocomplete already knows what particular methods are available for the object myfile. If clang already knows that then I suppose it should also know where that method is. – Tito Nov 12 '12 at 08:04
  • Separation of concerns. The completion mechanism and the "Go to declaration" mechanism are totally separate. The completion mechanism provided by clang_complete uses `clang` as a backend while the "Go to declaration" mechanism is entirely dependent on `tags` file(s) generated by `ctags`: when you do ``, Vim searches your `tags` file(s) for the word under the cursor. No `tags` file: no "Go to declaration". Standard or local. Simple. If you want Vim to "Go to declaration" on a standard method you *must* provide a `tags` file generated against the standard library's headers. – romainl Nov 12 '12 at 08:48
0

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.

Johan
  • 20,067
  • 28
  • 92
  • 110