Home > Ruby, vim > vim-ruby-refactoring – Extract Method

vim-ruby-refactoring – Extract Method

31 December, 2010

This post is part of a series which documents the vim-ruby-refactoring plugin.

IMPORTANT: As well as installing the vim-ruby-refactoring plugin, you must also install the matchit.vim plugin for this refactoring to work.

Extract Method

Extracts a selection into a method and places it above the current method.

The refactoring: http://www.refactoring.com/catalog/extractMethod.html


Before refactoring:
Visually select lines you wish to extract
Hit your <leader-key> then type rem
You will now see a prompt to enter the new method name: 
Method name: print_details

After refactoring:
A new method print_details has been added above the print_owing method containing the contents of the selected lines.

rem is the default binding for this refactoring, think Refactor Extract Method.

  1. No comments yet.
  1. 31 December, 2010 at 1:44 am
Comments are closed.
%d bloggers like this: