A lightweight plugin that creates a variable from the highlighted text and inserts it on the line above, and replaces your expression with the variable name
Windows / OSX / Linux:
ALT+V- Extract Variable
- Select the expression you wish to put into a method and hit the Shortcut Key (
Alt+V) - Type the name of the new variable
You have two options, the easier of which is to install this package through Package Control.
####Package Control
- Ensure Package Control is installed and Sublime Text 2 has been restarted.
- Open the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows).
- Select "Package Control: Install Package"
- Select Ruby Extract Variable when the list appears.
Congratulations! The package is now installed on your system.
$ git clone git://github.com/shadowradiance/ruby-extract-variable.git RubyExtractVariableFurther instructions below.
Execute the commands below one by one in your Command prompt.
$ cd "%APPDATA%\Sublime Text 2\Packages"
$ git clone git://github.com/shadowradiance/ruby-extract-variable.git "RubyExtractVariable"Execute the commands below one by one in your terminal.
$ cd ~/.config/sublime-text-2/Packages/
$ git clone git://github.com/shadowradiance/ruby-extract-variable.git RubyExtractVariableThe plugin does not support multiple selections. If you select more than one block, only the first one will be used.
This plugin is heavily inspired by: