15

I wish to setup vim as C++ IDE so I can do all work from it.

I'm using these plugins for vim:

    • Clang complete - accurate completion
    • nerdtree - browse files
    • snipmate - insert snippets
    • AutoComplPop - omni-completion
    • buffergator - buffer management
    • vim-powerline - nice statusbar
    • vundle - to manage plugins

But I lack things like Jump to definition and compiling multiple files in one executable, project view...

I'm using

nmap <F8> :w % <bar> :!g++ -W -Wall -Wextra -pedantic -std=c++11 % -o %:t:r<CR> <bar> :!./%:t:r<CR>

to compile current file, but it won't work if there are multiple file that create one executable.

I know I could just use eclipse, netbeans, code::blocks and such, but I really like vim... If such thing as vim ide isn't possible do I have to learn GNU build system or some other method?

Any advice is welcome.

RedSparrow
  • 307
  • 1
  • 3
  • 9
  • 2
    If you write a quick makefile (Or have one generated) you can just run !make – Daniel Gratzer Nov 19 '12 at 15:12
  • 2
    @jozefg, `!make` will just run external make and that's it. there is built-in `make` command in vim which will also create a `quickfix` window with errors/warnings. It's much more useful –  Nov 19 '12 at 15:16

4 Answers4

6

You need to create a makefile which handles the build process.

Then from vim just run :make, it will run the build and pop all errors in quickfix window where you can navigate and jump to error locations.

2

First, to jump to definitions, you might try this:

I haven't tested it, so I can't tell you if it works.

Now, to build multiple file projects, it might be better for you to learn how to use makefiles and automake. These links might help you:

Good luck.

Edit: A similar question was answered on this link: https://stackoverflow.com/a/563992/1820837

Community
  • 1
  • 1
Guilherme
  • 693
  • 6
  • 9
2

"Jump to definition" is already there, it's <C-]> with the cursor on a keyword or :tag foo on the command line.

For these to work, you need a tags file generated by exuberant-ctags and to tell Vim where to find it. See :help tags and :help ctags.

Without a tags file, gd goes to the definition of the keyword under your cursor if it's in the same file. But it's not as generally useful as <C-]>.

romainl
  • 158,436
  • 18
  • 236
  • 264
  • Everything is correct, but, as usually, I would add the same suggestion: I recommend not to deal with ctags manually, but use plugin Indexer instead ( http://goo.gl/Q744m ), it does all the painful work automatically: it silently generates your tags, tells Vim where to look for it, and keeps tags up-to-date. All the work is done in background, so, you don't need to wait for it. – Dmitry Frank Nov 20 '12 at 06:00
1

For "Jump to definition" I can recommend the YouCompleteMe, plugin which is really easy to setup with vundle.

Otherwise there is also ctags, but I find it less useful.

To use vim as a IDE, I find this post useful.

Community
  • 1
  • 1
Løiten
  • 2,907
  • 3
  • 17
  • 32