RubyMine 2020.1 Help

Refactor code

Refactoring is the process of modifying source code in order to make it easier to maintain and extend, but without changing its behavior. RubyMine supports various refactoring operations for different programming languages. This topic mostly covers refactorings available for Ruby.

Invoke refactoring

  1. Select an item to refactor. You can select a file/folder in the Project tool window or expression/symbol in the editor.

  2. Press Ctrl+Shift+Alt+T to open a list of refactorings that can be selected.

    refactor this popup
    Alternatively, you can use a keyboard shortcut for a specific refactoring.

If you need to undo your refactoring, pressCtrl+Z.

Preview refactoring changes

For some refactorings, RubyMine lets you preview changes before applying them.

  1. To see potential changes (the list of usages where the refactoring will be performed), click Preview in the Refactoring Preview dialog.

  2. Check the changes that are going to be made in the Find tool window. You can exclude Delete or remove Ctrl+X changes that you consider unnecessary.

    Refactoring Preview window

  3. Click Do Refactor to proceed with the changes.

Configure refactoring settings

  1. In the Settings/Preferences dialog Ctrl+Alt+S, select Editor | General.

  2. On the General page, in the Refactorings section, adjust the refactoring options and click OK.

Refactorings supported in RubyMine

Rename Refactorings Refactor | Rename Shift+F6
Move and Copy Refactorings Refactor | Move
Refactor | Copy
Introduce Variable Refactor | Extract | Variable Ctrl+Alt+V
Extract Constant Refactor | Extract | Constant Ctrl+Alt+C
Introduce Field Refactor | Extract | Field Ctrl+Alt+F
Extract Parameter Refactor | Extract | Parameter Ctrl+Alt+P
Extract Method Refactor | Extract | Method Ctrl+Alt+M
Extract Superclass Refactor | Extract | Superclass
Extract Module Refactor | Extract | Module
Inline Refactor | Inline Ctrl+Alt+N
Pull Members Up, Push Members Down Refactor | Pull Members Up
Refactor | Push Members Down
Safe Delete Refactor | Safe Delete Alt+Delete
Extract Partial Refactor | Extract | Partial
Extract Include File Refactor | Extract | Extract Include File
Last modified: 29 May 2020