Automated Refactorings in RubyMine

June 23, 2013 Jared Carroll

Refactoring is the process of changing the internal structure of code without changing its external behavior. Successful refactorings involve taking very small, sometimes tedious, steps. Fortunately, many refactorings are simple enough to be automated. In this post, we’ll look at automated refactorings in RubyMine on OS X.


When the name of a variable, method, or class doesn’t explain its purpose, rename it with shift + F6.


Extract Variable

Help explain complex expressions by introducing variables with command + option + V.

extract variable

Extract Method

Move related logic into a separate method with command + option + M.

extract method

Inline Variable or Method

Inline variables and methods that don’t increase clarity with command + option + N

inline method

Additional Refactorings

Less frequently used refactorings, such as extracting a superclass or module, are available from the “Refactor This…” dialog, control + T.

refactor this dialog

Automation Makes a Difference

Refactoring is a significant part of everyday development. It’s the final step in TDD’s mantra of red, green, refactor. We often refactor inherited code to help us better understand it. Automating refactoring encourages more refactoring. If a simple class rename involves ack and sed, then it’s time to upgrade to an IDE.

About the Author


More Content by Jared Carroll
Ember.js and SoundManager2, Part 2 – Tests and StateManager
Ember.js and SoundManager2, Part 2 – Tests and StateManager

If you have read the first part of this series you may have noticed an issue with the implementation propos...

The Pivotal Tracker Rewrite, And Improved Story Linking
The Pivotal Tracker Rewrite, And Improved Story Linking

If you’re a long time Pivotal Tracker user, you’ve probably noticed that for the last year or so, things ha...


Subscribe to our Weekly Newsletter

Thank you!
Error - something went wrong!