|
| 1 | +# Ruby Refactoring Tool for Vim |
| 2 | + |
| 3 | +I love vim! It's my editor of choice when I am developing software. |
| 4 | + |
| 5 | +Currently (for the last 4 years at least) I have been working mainly |
| 6 | +with the Ruby Programming Language. |
| 7 | + |
| 8 | +I have been missing a refactoring tool for a while (like the ones you |
| 9 | +can find in IDE's) while I am developing, but I never had the nerve |
| 10 | +to dwell into vim script to actually code my own. |
| 11 | + |
| 12 | +Recently (a couple of weeks ago) Gary Bernhardt presented his vim |
| 13 | +configuration in the Software Craftsmanship User Group UK and he |
| 14 | +showed us the two refactoring patterns he has written in vim script. |
| 15 | + |
| 16 | +Initially I just thought "cool", but it didn't really sink in until |
| 17 | +a couple of weeks later. |
| 18 | + |
| 19 | +So now I have decided to code this in vim script, but I am not sure how far |
| 20 | +I will go with it (clone at your own risk). |
| 21 | + |
| 22 | + N.B. 'Rename Local Variable', 'Rename Instance Variable' and 'ExtractMethod' require matchit.vim: |
| 23 | + |
| 24 | +[http://www.vim.org/scripts/script.php?script_id=39](http://relishapp.com/despo/vim-ruby-refactoring) |
| 25 | + |
| 26 | +## Implemented commands/patterns: |
| 27 | + |
| 28 | + :RAddParameter - Add Parameter |
| 29 | + :RInlineTemp - Inline Temp |
| 30 | + :RConvertPostConditional - Convert Post Conditional |
| 31 | + :RExtractConstant - Extract Constant (visual selection) |
| 32 | + :RExtractLet - Extract to Let (Rspec) |
| 33 | + :RExtractLocalVariable - Extract Local Variable (visual selection) |
| 34 | + :RRenameLocalVariable - Rename Local Variable (visual selection/variable under the cursor, *REQUIRES matchit.vim*) |
| 35 | + :RRenameInstanceVariable - Rename Instance Variable (visual selection, *REQUIRES matchit.vim*) |
| 36 | + :RExtractMethod - Extract Method (visual selection, *REQUIRES matchit.vim*) |
| 37 | + |
| 38 | +Default bindings: |
| 39 | + |
| 40 | + :nnoremap <leader>rap :RAddParameter<cr> |
| 41 | + :nnoremap <leader>rcpc :RConvertPostConditional<cr> |
| 42 | + :nnoremap <leader>rel :RExtractLet<cr> |
| 43 | + :vnoremap <leader>rec :RExtractConstant<cr> |
| 44 | + :vnoremap <leader>relv :RExtractLocalVariable<cr> |
| 45 | + :nnoremap <leader>rit :RInlineTemp<cr> |
| 46 | + :vnoremap <leader>rrlv :RRenameLocalVariable<cr> |
| 47 | + :vnoremap <leader>rriv :RRenameInstanceVariable<cr> |
| 48 | + :vnoremap <leader>rem :RExtractMethod<cr> |
| 49 | + |
| 50 | +Additional usage examples (thanks Justin!): |
| 51 | +[http://justinram.wordpress.com/2010/12/30/vim-ruby-refactoring-series/](http://justinram.wordpress.com/2010/12/30/vim-ruby-refactoring-series/) |
| 52 | + |
| 53 | +## Documentation |
| 54 | +[http://relishapp.com/despo/vim-ruby-refactoring](http://relishapp.com/despo/vim-ruby-refactoring) |
| 55 | + |
| 56 | +Enrique Comba Riepenhausen & Paul King |
| 57 | + |
0 commit comments