JohnTortugo
JohnTortugo

Reputation: 6625

Using vim for coding with in a big C++ project

Is there any plugin for VIM that I can use to index an C++ project code base?

I would apreciate functionalities like being capable of specifing a class and and may be a method and see what file/line the method/class is defined.

Upvotes: 14

Views: 22176

Answers (3)

Luc Hermitte
Luc Hermitte

Reputation: 32926

Regarding code navigation (and completion),

I'd take a look at clang_indexer (and clang_complete) -- ctag understanding of C++ code is quite bad, but universal-ctags has greatly improved the situation ; cscope understanding of C++ is non-existent.

Regarding plugins for C++ coding,

I have a suite for C and C++ programming. It is mainly oriented toward C++ programming, however a few, and unique features can be used in C as well:

  • context sensitive snippets (they require other plugins I'm maintaining);
  • a way to jump to a function definition from its declaration (or create it on the fly if it doesn't exists yet) (it used to requires the plugin alternate, which is a must have, however that I've forked it for my own needs) -> :GOTOIMPL;
  • a little tool that lists functions with a declaration and no definition, or functions with a definition and no declaration (NB: I haven't used it against C static function yet) (it requires ctags).
  • :Override that searches for overridable functions
  • :DOX that analyses C++ function signature to generate the appropriate (customizable) doxygen comment (with \param, \throw, ...)
  • a mapping to include the header file where the symbol under the cursor is defined* (which requires an up-to-date ctags base)
  • and few other things

Otherwise, I also use:

  • plugins like project/local_vimrc in order to have project specific settings ;
  • searchInRuntime to open/jump to files without the need to browse the directories of the current project ;
  • a refactoring plugin (that still lacks a few things ...) ;
  • a wrapper around :make in order to do background compiling, and to filter &makeprg results (e.g. pathnames conversions between cygwin posix form and dos form ; application of STLfilt ; etc.) (-> BuildToolWrapper which is stable, but still in an alpha stage) ;
  • and a few other things which have already been mentioned (alternate, ctags, ...).

Other Plugins.

Other people use c.vim, other templating systems (snipmate & co), pyclewn (that I highly recommend for debugging (with gdb) from within vim), other bracket-surrounding-and-expansion systems, ...

PS: I've answered, slightly differently, a question on the same subject on quora.

Upvotes: 23

Fredrik Pihl
Fredrik Pihl

Reputation: 45662

I use taglist extensively.

The "Tag List" plugin is a source code browser for the Vim editor. It provides an overview of the structure of source code files and allows you to efficiently browse through source code files in different programming languages. It is the top-rated and most-downloaded plugin for the Vim editor.

Upvotes: 2

Sanish
Sanish

Reputation: 1719

cscope is a nice tool for browsing. There is nice tutorial here.

ctags is another nice tool, I use it in my projects. Tutorial here. If you are in Ubuntu, you can install ctags by doing:

apt-get install exuberant-ctags

gtags is another tool.

Upvotes: 3

Related Questions