Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

vim

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.

like image 885
JohnTortugo Avatar asked Jun 21 '12 03:06

JohnTortugo


1 Answers

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.

like image 164
Luc Hermitte Avatar answered Sep 18 '22 19:09

Luc Hermitte