Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Refactoring tool for Ruby in vim!
VimL Ruby
branch: master
Failed to load latest commit information.
autoload Enhanced extract method to always place extracted method below origin…
features Merge pull request #33 from pythonandchips/introduce_variable
plugin Let user disable default mappings
test Adding Extract Method feature and removing manual test case.
.gitignore Ignore generated doc tags
.rvmrc Setting up the structure for a cucumber test, though it doesn't actually
.travis.yml not sure if the indentation has soemthing to do with travis ont using…
Gemfile added rake to the gemfile as it is needed by travis
Gemfile.lock Update Gems to latest versions adding readme in features
Rakefile Rollback changes to Rakefile
cucumber.yml ignore issues tag when running cukes

Ruby Refactoring Tool for Vim

I love vim! It's my editor of choice when I am developing software.

Currently (for the last 4 years at least) I have been working mainly with the Ruby Programming Language.

I have been missing a refactoring tool for a while (like the ones you can find in IDE's) while I am developing, but I never had the nerve to dwell into vim script to actually code my own.

Recently (a couple of weeks ago) Gary Bernhardt presented his vim configuration in the Software Craftsmanship User Group UK and he showed us the two refactoring patterns he has written in vim script.

Initially I just thought "cool", but it didn't really sink in until a couple of weeks later.

So now I have decided to code this in vim script, but I am not sure how far I will go with it (clone at your own risk).

N.B. 'Rename Local Variable', 'Rename Instance Variable' and 'ExtractMethod' require matchit.vim:

Implemented commands/patterns:

:RAddParameter           - Add Parameter 
:RInlineTemp             - Inline Temp
:RConvertPostConditional - Convert Post Conditional
:RExtractConstant        - Extract Constant          (visual selection)
:RExtractLet             - Extract to Let (Rspec)
:RExtractLocalVariable   - Extract Local Variable    (visual selection)
:RRenameLocalVariable    - Rename Local Variable     (visual selection/variable under the cursor, *REQUIRES matchit.vim*)
:RRenameInstanceVariable - Rename Instance Variable  (visual selection, *REQUIRES matchit.vim*)
:RExtractMethod          - Extract Method            (visual selection, *REQUIRES matchit.vim*)

Default bindings:

:nnoremap <leader>rap  :RAddParameter<cr>
:nnoremap <leader>rcpc :RConvertPostConditional<cr>
:nnoremap <leader>rel  :RExtractLet<cr>
:vnoremap <leader>rec  :RExtractConstant<cr>
:vnoremap <leader>relv :RExtractLocalVariable<cr>
:nnoremap <leader>rit  :RInlineTemp<cr>
:vnoremap <leader>rrlv :RRenameLocalVariable<cr>
:vnoremap <leader>rriv :RRenameInstanceVariable<cr>
:vnoremap <leader>rem  :RExtractMethod<cr>

Additional usage examples (thanks Justin!):


Enrique Comba Riepenhausen & Paul King

Something went wrong with that request. Please try again.