4

I have been setting up my development environment in Vim for a while now. Since all my projects are in C++11 I have found some plugins that made my life easier and almost as good as the days of Intellij and Java. However there are still some things missing.

The main feature I miss is the refactoring utilities (rename across project, refactor code into functions/classes, remove classes, ...). Any recommendations on how I can get such functionality in vim?

I am using the following plugins:


gmarik/vundle
Valloric/YouCompleteMe
a.vim
wincent/Command-T
DoxygenToolkit.vim
scrooloose/nerdtree
godlygeek/tabular
tpope/vim-sensible
tpope/vim-unimpaired
tpope/vim-endwise
tpope/vim-fugitive
jeffkreeftmeijer/vim-numbertoggle
Lokaltog/vim-easymotion
rstacruz/sparkup'
Mizuchi/STL-Syntax


If you want the full details, here is my .vimrc (feel free to contribute to it in the gist):

https://gist.github.com/MauricioCarneiro/9547864

Carneiro
  • 3,379
  • 3
  • 22
  • 33
  • Honestly, why not hack up your own? Good learning experience. Maybe pick up the project mentioned in romainl's answer and bring it up to date. – Mark Mar 14 '14 at 23:02

4 Answers4

4

In my plugins suites, you'll found:

  • lh-cpp (various things dedicated to C++)
  • lh-brackets (smart insertions of brackets, surrounding, ...)
  • mu-template, with advanced C++ aware templates and snippets
  • a local_vimrc plugin to help define projects
  • BuildWrapperTools that
    • wraps calls to make,
    • provides filters to compilers outputs (to add STLfilt on the fly for instance),
    • permits to switch between debug/Release/whatever configuration (for projects under CMake) ; example here
  • lh-refactor (generic refactoring suite)

On github, I also have an experimental project to wrap clang-indexer.

Luc Hermitte
  • 29,719
  • 7
  • 60
  • 74
3

I think you will need Ultisnips, Tagbar and tcomment plugin, especially Ultisnips.

More information about configuration, please refer:https://github.com/xautjzd/dotvim

xautjzd
  • 213
  • 1
  • 11
  • good recommendations. I was curious why you use Ultisnips but not honza/vim-snippets in your .vimrc? – Carneiro Mar 16 '14 at 11:22
1

The only refactoring tool for c++11 I know of is clang-modernize from LLVM and Intel guys (Chandler Carruth from Google gave a speech about it on youtube). You can run it from vim as any other cli tool, e.g.:

:!clang-modernize -style=Google -format -loop-convert -pass-by-value -replace-auto_ptr -use-nullptr -use-auto -add-override -override-macros %

The % sign at the end will expand to your current file's path. There's more tools available nowadays, like clangtidy and cquery.

You can probably make all fixers and linters auto correct your code as you type with something like ALE vim plugin. Alternatively (and this is my preferred solution) you could use a dedicated language server and coc.nvim plugin which allows for a full IDE experience (with code specific fixers, snippets, jump to definition, find all interface implementations, etc.).

cprn
  • 909
  • 1
  • 11
  • 20
0

Refactor is the only C++ refactoring plugin on vim.org. Its latest update is from 2007, though, so I'm not sure it will work for C++11.

You could also try Eclim, an Eclipse/Vim plugin that lets you use a number of Eclipse features from Vim.

romainl
  • 158,436
  • 18
  • 236
  • 264