lh-refactor is a generic refactoring plugin.
So far it supports the following refactorings (v0.2.2):
- Extract Function,
- Extract Variable,
- Extract Type,
- Extract Getter & Extract Setter, (it's more a generate than an extract actually) and the following languages: C, C++, Java, Pascal, VimL.
The list of languages supported can be extended (however some refactoring work in the plugin is required to simplify that part)
The complete documentation can be browsed in the repository
<C-X>f
to eXtract a Function<C-X>v
to eXtract a Variable<C-X>t
to eXtract a Type
<C-X>g
to eXtract a Getter, and<C-X>s
to eXtract a Setter<C-X>p
and<C-X>P
to Put back the definition that as been extracted
The extraction refactorings don't put back anything. The position in the code
where the extracted things are to be placed are left to end-user appreciation.
This has to be done with <C-X>p
and <C-X>P
.
-
Requirements: Vim 7.+, lh-vim-lib, lh-brackets, lh-dev (and thus lh-tags), and lh-style
-
With vim-addon-manager, install lh-refactor. This is the preferred method because of the various dependencies.
ActivateAddons lh-refactor
-
or you can clone the git repositories (expecting I haven't forgotten anything):
git clone [email protected]:LucHermitte/lh-vim-lib.git git clone [email protected]:LucHermitte/lh-tags.git git clone [email protected]:LucHermitte/lh-dev.git git clone [email protected]:LucHermitte/lh-style.git git clone [email protected]:LucHermitte/lh-brackets.git git clone [email protected]:LucHermitte/vim-refactor.git # For experimental function extraction git clone [email protected]:LucHermitte/mu-template.git git clone [email protected]:tomtom/stakeholders_vim.git
-
or with Vundle/NeoBundle (expecting I haven't forgotten anything):
Bundle 'LucHermitte/lh-vim-lib' Bundle 'LucHermitte/lh-tags' Bundle 'LucHermitte/lh-dev' Bundle 'LucHermitte/lh-style' Bundle 'LucHermitte/lh-brackets' Bundle 'LucHermitte/vim-refactor' " For experimental function extraction Bundle 'LucHermitte/mu-template' Bundle 'tomtom/stakeholders_vim'
- Klaus Horsten's tip: Vim as refactoring tool (with examples in C#)
- lh-cpp defines a few other refactoring-like functionalities:
- Generate accessor and mutator (
:ADDATTRIBUTE
), - Generate default body given a function signature (
:GOTOIMPL
)
- Generate accessor and mutator (
- Refactoring.com