# Refactor code

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

[Refactoring](https://en.wikipedia.org/wiki/Code_refactoring) is a process of improving your source code without creating a new functionality. Refactoring helps you keep your code solid  and easy to maintain.

## Invoke refactoring

Procedure:

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+Alt+Shift+T` (Windows), `⌃ T` (macOS), `⌘ ⌥ ⇧ T` (IntelliJ IDEA Classic (macOS)), `⌃ S` (macOS System Shortcuts), `Ctrl+Alt+Shift+T` (XWin), `Ctrl+Alt+Shift+T` (GNOME), `Ctrl+Alt+Shift+T` (KDE), `Ctrl+Alt+Shift+T` (Emacs), `Ctrl+Alt+Shift+T` (Sublime Text), `⌃ T` (Sublime Text (macOS)), `Ctrl+Shift+R` (Visual Studio), `⌘ ⇧ R` (Visual Studio (macOS)), `Meta+Alt+Shift+T` (TextMate), `Ctrl+Alt+Shift+T` (NetBeans), `Ctrl+Alt+Shift+T` (Eclipse), `⌃ T` (Eclipse (macOS)) to open a list of refactorings that can be selected.

![refactor this popup](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_refactor_this.png)

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

You can also make a [multi-caret selection](multicursor.html#add-carets-at-selected-locations) for an extended range of refactoring operations, including Encapsulate Fields, Move Static Members, Extract Delegate, Extract Interface, and Extract Superclass. To utilize this feature, place the caret in each member you want to apply the refactoring to, and the IDE will automatically preselect and check these members in the refactoring dialog.

If you need to undo your refactoring, press `Ctrl+Z` (Windows), `⌘ Z` (macOS), `⌘ Z` (IntelliJ IDEA Classic (macOS)), `⌘ Z` (macOS System Shortcuts), `Ctrl+Z` (XWin), `Ctrl+Z` (GNOME), `Ctrl+Z` (KDE), `Ctrl+Shift+Minus` (Emacs), `Ctrl+Z` (Sublime Text), `⌘ Z` (Sublime Text (macOS)), `Ctrl+Z` (Visual Studio), `⌘ Z` (Visual Studio (macOS)), `Meta+Z` (TextMate), `Ctrl+Z` (NetBeans), `Ctrl+Z` (Eclipse), `⌘ Z` (Eclipse (macOS)).

## Preview refactoring changes

Procedure:

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

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

2. In the  [Find](null) tool window that opens, check the changes that are going to be made. You can exclude `Delete` (Windows), `⌦` (macOS), `⌦` (IntelliJ IDEA Classic (macOS)), `⌦` (macOS System Shortcuts), `Delete` (XWin), `Delete` (GNOME), `Delete` (KDE), `Delete` (Emacs), `Delete` (Sublime Text), `⌦` (Sublime Text (macOS)), `Delete` (Visual Studio), `⌦` (Visual Studio (macOS)), `Delete` (TextMate), `Delete` (NetBeans), `Delete` (Eclipse), `⌦` (Eclipse (macOS)) or remove `Ctrl+X` (Windows), `⌘ X` (macOS), `⌘ X` (IntelliJ IDEA Classic (macOS)), `⌘ X` (macOS System Shortcuts), `Ctrl+X` (XWin), `Ctrl+X` (GNOME), `Ctrl+X` (KDE), `Shift+Delete` (Emacs), `Ctrl+X` (Sublime Text), `⌘ X` (Sublime Text (macOS)), `Ctrl+X` (Visual Studio), `⌘ X` (Visual Studio (macOS)), `Meta+X` (TextMate), `Ctrl+X` (NetBeans), `Ctrl+X` (Eclipse), `⌘ X` (Eclipse (macOS)) changes that you consider unnecessary.

![Refactoring Preview window](https://resources.jetbrains.com/help/img/idea/2026.3/rm_refactoring_rename_preview.png)

3. Click Refactor to proceed with the changes.

## Resolve conflicts

Procedure:

When RubyMine encounters problems with your refactoring, it opens a dialog with the list of conflicts and their brief descriptions.

* Click Refactor Anyway to ignore the problem and proceed.

* Click Open in Find Window to open the conflict entries in the Find tool window and deal with them further.

* In the Find tool window, you can apply the refactor by selecting Refactor or click Cancel and return to the editor.

## Configure refactoring settings

Procedure:

1. In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Meta+Comma` (TextMate), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))), select `Editor | Code Editing`.

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

## Refactorings supported in RubyMine

|  [Rename Refactorings](rename-refactorings.html)  |  `Refactor \| Rename`  |  `Shift+F6` (Windows), `⇧ F6` (macOS), `⇧ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ R` (macOS System Shortcuts), `Shift+F6` (XWin), `Shift+F6` (GNOME), `Shift+F6` (KDE), `Shift+F6` (Emacs), `Shift+F6` (Sublime Text), `⇧ F6` (Sublime Text (macOS)), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Shift+F6` (TextMate), `Ctrl+R` (NetBeans), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))  |
|  [Move and Copy Refactorings](move-refactorings.html)  |     `Refactor \| Move`       `Refactor \| Copy`     |     `F6` (Windows), `F6` (macOS), `F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ I` (macOS System Shortcuts), `F6` (XWin), `F6` (GNOME), `F6` (KDE), `F6` (Emacs), `F6` (Sublime Text), `F6` (Sublime Text (macOS)), `Ctrl+R, O` (Visual Studio), `⌘ R, O` (Visual Studio (macOS)), `F6` (TextMate), `Ctrl+M` (NetBeans), `Alt+Shift+V` (Eclipse), `⌘ ⌥ V` (Eclipse (macOS))       `F5` (Windows), `F5` (macOS), `F5` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ Y` (macOS System Shortcuts), `F5` (XWin), `F5` (GNOME), `F5` (KDE), `F5` (Emacs), `F5` (Sublime Text), `F5` (Sublime Text (macOS)), `F5` (Visual Studio), `F5` (Visual Studio (macOS)), `F5` (TextMate), `F5` (NetBeans), `F5` (Eclipse), `F5` (Eclipse (macOS))     |
|  [Introduce Variable](extract-variable.html)  |  `Refactor \| Extract \| Variable`  |  `Ctrl+Alt+V` (Windows), `⌘ ⌥ V` (macOS), `⌘ ⌥ V` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ V` (macOS System Shortcuts), `Ctrl+Alt+V` (XWin), `Ctrl+Alt+V` (GNOME), `Alt+Shift+V` (KDE), `Ctrl+Alt+V` (Emacs), `Ctrl+Alt+V` (Sublime Text), `Ctrl+Alt+V` (Sublime Text (macOS)), `Ctrl+R, V` (Visual Studio), `⌘ R, V` (Visual Studio (macOS)), `Meta+Alt+V` (TextMate), `Alt+Shift+V` (NetBeans), `Alt+Shift+L` (Eclipse), `⌘ ⌥ L` (Eclipse (macOS))  |
|  [Extract Constant](extract-constant.html)  |  `Refactor \| Extract \| Constant`  |  `Ctrl+Alt+C` (Windows), `⌘ ⌥ C` (macOS), `⌘ ⌥ C` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ C` (macOS System Shortcuts), `Ctrl+Alt+C` (XWin), `Ctrl+Alt+C` (GNOME), `Ctrl+Alt+C` (KDE), `Ctrl+Alt+C` (Emacs), `Ctrl+Alt+C` (Sublime Text), `⌘ ⌥ C` (Sublime Text (macOS)), `Ctrl+Alt+C` (Visual Studio), `⌘ ⌥ C` (Visual Studio (macOS)), `Ctrl+Alt+C` (TextMate), `Alt+Shift+C` (NetBeans), `Ctrl+Alt+C` (Eclipse), `Ctrl+Alt+C` (Eclipse (macOS))  |
|  [Introduce Field](extract-field.html)  |  `Refactor \| Extract \| Field`  |  `Ctrl+Alt+F` (Windows), `⌘ ⌥ F` (macOS), `⌘ ⌥ F` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ F` (macOS System Shortcuts), `Ctrl+Alt+F` (XWin), `Ctrl+Alt+F` (GNOME), `Ctrl+Alt+F` (KDE), `Ctrl+Alt+F` (Emacs), `Ctrl+Alt+F` (Sublime Text), `Ctrl+Alt+F` (Sublime Text (macOS)), `Ctrl+R, F` (Visual Studio), `⌘ R, F` (Visual Studio (macOS)), `Ctrl+Alt+F` (TextMate), `Alt+Shift+E` (NetBeans), `Ctrl+Alt+F` (Eclipse), `⌘ ⌥ F` (Eclipse (macOS))  |
|  [Extract Parameter](introduce-parameter.html)  |  `Refactor \| Extract \| Parameter`  |  `Ctrl+Alt+P` (Windows), `⌘ ⌥ P` (macOS), `⌘ ⌥ P` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ P` (macOS System Shortcuts), `Ctrl+Alt+P` (XWin), `Ctrl+Alt+P` (GNOME), `Ctrl+Alt+P` (KDE), `Ctrl+Alt+P` (Emacs), `Ctrl+Alt+P` (Sublime Text), `⌘ ⌥ P` (Sublime Text (macOS)), `Ctrl+R, P` (Visual Studio), `⌘ R, P` (Visual Studio (macOS)), `Meta+Alt+P` (TextMate), `Ctrl+Alt+P` (NetBeans), `Ctrl+Alt+P` (Eclipse), `⌘ ⌥ P` (Eclipse (macOS))  |
|  [Extract Method](extract-method.html)  |  `Refactor \| Extract \| Method`  |  `Ctrl+Alt+M` (Windows), `⌘ ⌥ M` (macOS), `⌘ ⌥ M` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ M` (macOS System Shortcuts), `Ctrl+Alt+M` (XWin), `Ctrl+Alt+M` (GNOME), `Ctrl+Alt+M` (KDE), `Ctrl+Alt+M` (Emacs), `Ctrl+Alt+M` (Sublime Text), `⌘ ⌥ M` (Sublime Text (macOS)), `Ctrl+R, M` (Visual Studio), `⌘ R, M` (Visual Studio (macOS)), `Meta+Alt+M` (TextMate), `Alt+Shift+M` (NetBeans), `Alt+Shift+M` (Eclipse), `⌘ ⌥ M` (Eclipse (macOS))  |
|  [Extract Superclass](extract-superclass.html)  |  `Refactor \| Extract \| Superclass`  |
|  [Extract Module](extract-module.html)  |  `Refactor \| Extract \| Module`  |
|  [Inline](inline.html)  |  `Refactor \| Inline`  |  `Ctrl+Alt+N` (Windows), `⌘ ⌥ N` (macOS), `⌘ ⌥ N` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ N` (macOS System Shortcuts), `Ctrl+Alt+N` (XWin), `Ctrl+Alt+N` (GNOME), `Ctrl+Alt+N` (KDE), `Ctrl+Alt+N` (Emacs), `Ctrl+Alt+N` (Sublime Text), `⌘ ⌥ N` (Sublime Text (macOS)), `Ctrl+R, I` (Visual Studio), `⌘ R, I` (Visual Studio (macOS)), `Meta+Alt+N` (TextMate), `Ctrl+Alt+N` (NetBeans), `Alt+Shift+I` (Eclipse), `⌘ ⌥ I` (Eclipse (macOS))  |
|  [Pull Members Up, Push Members Down](pull-members-up.html)  |     `Refactor \| Pull Members Up`       `Refactor \| Push Members Down`     |
|  [Safe Delete](safe-delete.html)  |  `Refactor \| Safe Delete`  |  `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Meta+Delete` (TextMate), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))  |
|  [Extract Partial](extract-partial.html)  |  `Refactor \| Extract \| Partial`  |
|  [Extract Include File](editing-html-files.html#javascript_extract_include_file)  |  `Refactor \| Extract \| Extract Include File`  |

