Refactoring C/C++ in Vim (e.g. method extraction like in Eclipse)

Bjarke Freund-Hansen picture Bjarke Freund-Hansen · Mar 18, 2010 · Viewed 15.1k times · Source

Are there any plugins or built-in methods in Vim for performing refactoring on C or C++ code, something like the refactoring tools in Eclipse?

I'm especially keen on the extract method refactoring tool from Eclipse that will determine parameters from new methods and typically also guess a variable to use as the return value.

Answer

Luc Hermitte picture Luc Hermitte · Sep 8, 2011

I've written a generic refactoring plugin. C++ is one of the primary languages handled (as it's my primary language at work). Method extraction is supported.

For C++, the plugin is able (thanks to ctags) to deduce most (but unfortunately not always all -- thanks to ctags...) of the variables coming in and out of the extracted function. I still have to write a little dialog box to select how the in/out variables shall be exchanged (const ref, rvalue ref, copy, pointer, tuples, struct, and so on) (BTW, help is welcome as GUIs are not my thing ^^').