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
Example
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.
Categories: Ruby, vim
ruby vim refactoring vim-ruby-refactoring
Comments (0)