Ⅰ. 插件描述
Refactoring for the rest of us! (automated refactoring in vim)Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'apalmer1377/factorus'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'apalmer1377/factorus'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'apalmer1377/factorus'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/apalmer1377/factorus
Ⅳ. 文档说明
# Factorus: automated refactoring in Vim
Factorus is a Vim plugin for automated refactoring. It provides
renaming of methods and classes, encapsulation of variables,
and even method extraction, with a few very intutitive commands.
Features
The following table shows which features Factorus supports for
which languages:
| Add Parameter | Encapsulate Variable | Extract Method (Automated) | Extract Method (Manual) | Rename Argument | Rename Class | Rename Method | Rename Field | |
|---|---|---|---|---|---|---|---|---|
| Java | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Python | ✓ | N/A | ✓ | ✓ | ✓ | ✓ | ✓ | N/A |
| C/C++ | ✓ | N/A | ✓ | ✓ | ✓ | N/A | ✓ | ✓ |
Additionally, for C/C++, Factorus supports the following refactorings:
| Rename Type | Rename Macro | Rename Namespace | |
|---|---|---|---|
| C/C++ | ✓ | ✓ | N/A |
NOTE: Factorus support for C++ currently uses the same code as for C; as such, Factorus may not work properly for more complex C++ code.
Factorus also has commands for reverting changes and rebuilding projects, for stability and sanity testing.
Examples
(All code shown either from spring-framework or git)
Rename Class

Rename Field

Rename Method

Rename Type

Rename Macro

Rename Arg

Add Parameter

Encapsulate Field

Extract Method
Factorus provides two functions for method extraction. The first, FExtractMethod, automatically finds a block
of code that can be safely extracted:

If you prefer to manually extract a block of code, however, you can use FMExtractMethod (now deprecated, use FExtractMethod:

Installation
There are many ways to install Factorus. You can:
- Use a plugin manager like pathogen or vim-plug (Recommended),
- Clone the repository into your
'runtimepath', or - Download the tar file from vim.org and extract it into your
'runtimepath'.