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

vim-ruby-refactoring – Extract Constant

30 December, 2010

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

Extract Constant

Extracts a selection into a constant which is placed at the top of the current module or class.

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


Before refactoring:
Visually select the value you wish to extract
Hit your <leader-key> then type rec
You will now see a prompt to enter the constant name: 
Constant name: Gravitational_Constant

After refactoring:
The value 9.81 has been extracted into a constant GRAVITATIONAL_CONSTANT which is placed at the top of the module.

rec is the default binding for this refactoring, think Refactor Extract Constant.

  1. No comments yet.
  1. 30 December, 2010 at 11:55 pm
Comments are closed.
%d bloggers like this: