Ⅰ. 插件描述
Some simple vim refactoring functions for your PHP codeⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'beberlei/vim-php-refactor'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'beberlei/vim-php-refactor'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'beberlei/vim-php-refactor'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/beberlei/vim-php-refactor
Ⅳ. 文档说明
# PHP Refactoring for VIM
Some very simple refactorings for PHP code using VIM:
- Extract Method
- Extract Variable
- Extract Interface
- Extract Class Property
- Rename Local Variable
- Rename Class Variable
- Implement all abstract functions
Requirements
- VIM Comma Object (austintaylor/vim-commaobject)
Mappings
Default key mappings defined:
vmap \em :call ExtractMethod()<CR>
nnoremap \ev :call ExtractVariable()<CR>
nnoremap \ep :call ExtractClassProperty()<CR>
nnoremap \ei :call ExtractInterface()<CR>
nnoremap \rlv :call RenameLocalVariable()<CR>
nnoremap \rcv :call RenameClassVariable()<CR>
nnoremap \iaf :call ImplementAbstractFunctions()<CR>
If you want avoid them being set put the following in your vimrc:
let g:no_php_maps = 1
Documentation
Extract Method
Extracts the current visual selection into a private method.
The code will be pasted inline at the current location
and has to be moved around.
Extract Variable
Extract the current argument under the cursor into a variable
right above the method call.
Extract Interface
Create an interface of all constants, public functions and
properties of the current class (the current file actually).
The interface is created below the class and can then moved
around.
Extract Class Property
Turn a local variable into a class property.
Rename local variable
Renames variable under cursor inside a function/method to a new name.
Rename class variable
Renames variable under cursor inside the whole class. No renaming of
getter/setter or checking for breaks in related classes takes place.
Implement all abstract functions
If you copy the body of abstract class or interface into a concrete implementation class,
and then execute this refactoring. It will turn all abstract methods into empty body
methods throwing a runtime exception.