Configuring Vim For C++ - Stack Overflow
Configuring Vim For C++ - Stack Overflow
Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen
now
I would like to make vim my C++ editor. I have very little experience working with it and need help in
configuring vim to work with C++. I need such features as
105 code-complete (for stl and for my classes)
switching between .cc and .h files
may be some more tricks you, C++ and vim gurus, have.
130 May be you could provide some configs (with explanations), or links to tutorials, plugins I could
make use of?
4 +1 for the sheer masochism of wanting to use vim as your IDE :) vim has its uses (especially for editing files
remotely in my experience), but anyone who actually wants to use it for code editing has chutzpah in my view.
– Stuart Golodetz Nov 21 '10 at 15:35
34 @sgolodetz: Then there are quite a lot of people with chutzpah out there. – Cascabel Nov 21 '10 at 16:35
1 @Jefromi: Yup I do realise that :) It has always seemed like masochism to me though...in a sort of slightly
admirable way. – Stuart Golodetz Nov 21 '10 at 16:40
4 In retrospect, I guess posting the equivalent of "I'm a bit dubious about vim" on a post likely to be frequented
by a lot of vim enthusiasts might have been a little provocative -- it was meant to be a tongue-in-cheek
comment rather than the start of an argument though. – Stuart Golodetz Nov 21 '10 at 21:44
3 Answers
I've fixed the link to my C&C++ ftplugins suite. Thanks for the "advertizing" :) – Luc Hermitte Nov 21 '10 at
21:25
Also I may recomend FSwitch plugin instead of A plugin. – W55tKQbuRu28Q4xv Feb 26 '13 at 4:13
1 Luc's lhCpp is incompatible with vundle (I think due to svn repo) and no install process I like personally -
recommend checking out github.com/Raimondi/delimitMate – netpoetica Sep 15 '13 at 14:28
2 +1 a very complete (and up to date) answer deserves it, it's nice to see some of the more reclusive members
posting these great answers. How thorough your answer is, is quite helpful, while at the same time not
overwhelming, even to a new vim user. – osirisgothra Jul 21 '14 at 10:58
1 How about vim-rtags? It's good for c++ code navigation, has a rename functionality. – P4C Jul 28 '16 at 9:57
I'm using vim as my C++ editor, however I'm not using many 'exotic' stuff.
I have several functions for "code snippets" like things, for example :
function! IncludeGuard()
let basename = expand("%:t:r")
let includeGuard = '__' . basename . '_h__'
call append(0, "#ifndef " . includeGuard)
call append(1, "#define " . includeGuard)
call append(line("$"), "#endif /* !" . includeGuard . " */")
endfunction
The only plugin I really couldn't live without is Command-T (which requires ruby support)
For easy .cc to .h switching, you can try this plugin
https://stackoverflow.com/questions/4237817/configuring-vim-for-c 2/3
10/25/2019 Configuring Vim for C++ - Stack Overflow
answered Nov 21 '10 at 12:46
icecrime
58k 9 87 105
Nice function. I was looking for something like that.... – Jepessen May 11 '17 at 9:59
NERDTree http://www.vim.org/scripts/script.php?script_id=1658
snipmate: http://www.vim.org/scripts/script.php?script_id=2540
I don't do omnicompletion just the usual ^n ^p stuff but there are plenty of resources to google for.
https://stackoverflow.com/questions/4237817/configuring-vim-for-c 3/3