Home > Ruby, vim > vim-ruby-refactoring – Extract Local Variable

vim-ruby-refactoring – Extract Local Variable

31 December, 2010

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

Extract Local Variable

Extracts a visual selection into a local variable.

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

Example

Before refactoring:
ExtractVar_Before
Visually select the value you wish to extract
Hit your <leader-key> then type relv
You will now see a prompt to enter the variable name: 
Variable name: mac_os

After refactoring:
ExtractVar_After
The value platform.upcase.include?(‘MAC’) has been extracted into a local variable mac_os.

relv is the default binding for this refactoring, think Refactor Extract Local Variable.

About these ads
  1. No comments yet.
Comments are closed.
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: