Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

VIM plugin is now maintained in a seperate repository

  • Loading branch information...
commit 7757d959074901a7c9ca452bcce699242aa2a160 1 parent a809007
@tomphp tomphp authored
Showing with 3 additions and 131 deletions.
  1. +3 −2 README.md
  2. +0 −129 docs/vim-bindings.vim
View
5 README.md
@@ -36,8 +36,9 @@ It outputs a diff to the screen and you can apply it to your code by piping it t
php refactor.phar <refactoring> <arg1>...<argN> | patch -p1
### VIM Bindings
-Some basic VIM bindings are included in the `docs` folder. A more complete VIM
-plugin will be available in the future.
+
+There is now a VIM plugin for using PHP refactorings within VIM. This plugin
+is maintained as a seperate project which can be found at https://github.com/vim-php/vim-php-refactoring
## Why?
View
129 docs/vim-bindings.vim
@@ -1,129 +0,0 @@
-" Some basic VIM bindings to run the refactor commands.
-"
-" This needs to be put into a proper vim plugin bundle but this bit of
-" vimscript provides some basic bindings until it is done properly.
-"
-" INSTALLATION
-"
-" Either save this file some where safe and add the following line to your
-" .vimrc file:
-"
-" source path/to/this/file
-"
-" Or simply copy the contents of this file into your .vimrc
-"
-" USAGE
-"
-" The file you are refactoring MUST be saved before any refactoring commands
-" will work.
-"
-" - EXTRACT METHOD
-" Go into visual mode and select the code you want to extract to a new
-" method the press <Leader>rem
-"
-" You will be prompted for the name of the new method.
-"
-" - RENAME LOCAL VARIABLE
-" In normal mode move the cursor so it's inside the name of the variable
-" which you want to rename. Press <Leader>rlv
-"
-" You will be prompted for the new name of the variable.
-"
-" - LOCAL VARIABLE TO INSTANCE VARIABLE
-" In normal mode move the cursor so it's inside the name of the variable
-" which you want to rename. Press <Leader>rli
-"
-" - OPTIMIZE USE
-" Simple press <Leader>rou to run the optimize use refactoring.
-
-let g:php_refactor_command='php /usr/bin/refactor.phar'
-let g:php_refactor_patch_command='patch -p1'
-
-func! PhpRefactorExtractMethod()
- " check the file has been saved
- if &modified
- echom 'Cannot refactor; file contains unsaved changes'
- return
- endif
-
- let startLine = line('v')
- let endLine = line('.')
- let method = input('Enter extracted method name: ')
-
- " check line numbers are the right way around
- if startLine > endLine
- let temp = startLine
- let startLine = endLine
- let endLine = temp
- endif
-
- let range = startLine . '-' . endLine
-
- let args = [range, method]
-
- call PhpRefactorRunCommand('extract-method', args)
-
- " todo : exit visual mode
-endfunc
-
-func! PhpRefactorLocalVariableToInstanceVariable()
- " check the file has been saved
- if &modified
- echom 'Cannot refactor; file contains unsaved changes'
- return
- endif
-
- let variable = expand('<cword>')
- let lineNo = line('.')
-
- let args = [lineNo, variable]
-
- call PhpRefactorRunCommand('convert-local-to-instance-variable', args)
-endfunc
-
-func! PhpRefactorRenameLocalVariable()
- " check the file has been saved
- if &modified
- echom 'Cannot refactor; file contains unsaved changes'
- return
- endif
-
- let oldName = expand('<cword>')
- let lineNo = line('.')
- let newName = input('Enter new variable name: ')
-
- let args = [lineNo, oldName, newName]
-
- call PhpRefactorRunCommand('rename-local-variable', args)
-endfunc
-
-func! PhpRefactorOptimizeUse()
- " check the file has been saved
- if &modified
- echom 'Cannot refactor; file contains unsaved changes'
- return
- endif
-
- call PhpRefactorRunCommand('optimize-use', [])
-endfunc
-
-func! PhpRefactorRunCommand(refactoring, args)
- " Enable autoread to stop prompting for reload
- setlocal autoread
-
- let command = ':!' . g:php_refactor_command
- \ . ' ' . a:refactoring . ' %'
-
- for arg in a:args
- let command = command . ' ' . arg
- endfor
-
- exec command .' | '.g:php_refactor_patch_command
-
- setlocal noautoread
-endfunc
-
-vnoremap <expr> <Leader>rem PhpRefactorExtractMethod()
-noremap <expr> <Leader>rlv PhpRefactorRenameLocalVariable()
-noremap <expr> <Leader>rli PhpRefactorLocalVariableToInstanceVariable()
-noremap <expr> <Leader>rou PhpRefactorOptimizeUse()
Please sign in to comment.
Something went wrong with that request. Please try again.