> vim-ruby-refactoring – Extract Constant
vim-ruby-refactoring – Extract Constant
This post is part of a series which documents the vim-ruby-refactoring plugin.
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
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
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.