# Refactoring

[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 , [dry](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself),  and easy to maintain.

Procedure: 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+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)), `⌘ ⌃ ⌥ T` (Xcode), `Ctrl+Shift+R` (Visual Studio), `⌘ ⇧ R` (Visual Studio (macOS)), `Ctrl+Shift+R` (ReSharper), `⌘ ⇧ R` (ReSharper (macOS)), `Ctrl+Alt+Shift+T` (QtCreator), `⌃ T` (QtCreator (macOS)), `Ctrl+Alt+Shift+T` (NetBeans), `Ctrl+Alt+Shift+T` (Eclipse), `⌃ T` (Eclipse (macOS)) to open the list of refactorings:

![Refactor This popup](https://resources.jetbrains.com/help/img/idea/2026.2/cl_refactoring_invoke.png)

Procedure: Undo 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)), `⌘ Z` (Xcode), `Ctrl+Z` (Visual Studio), `⌘ Z` (Visual Studio (macOS)), `Ctrl+Z` (ReSharper), `⌘ Z` (ReSharper (macOS)), `Ctrl+Z` (QtCreator), `⌘ Z` (QtCreator (macOS)), `Ctrl+Z` (NetBeans), `Ctrl+Z` (Eclipse), `⌘ Z` (Eclipse (macOS)).

Procedure: Preview changes

For some refactorings, you can preview changes before applying them.

1. Click Preview in the Refactoring Preview dialog:

![Refactoring dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_refactoring_dialog.png)

2. Check the changes that are going to be made in the [Find](find-tool-window.html) tool window. 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)), `⌫` (Xcode), `Delete` (Visual Studio), `⌦` (Visual Studio (macOS)), `Delete` (ReSharper), `⌦` (ReSharper (macOS)), `Delete` (QtCreator), `⌦` (QtCreator (macOS)), `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)), `⌘ X` (Xcode), `Ctrl+X` (Visual Studio), `⌘ X` (Visual Studio (macOS)), `Ctrl+X` (ReSharper), `⌘ X` (ReSharper (macOS)), `Ctrl+X` (QtCreator), `⌘ X` (QtCreator (macOS)), `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.2/cl_refactoring_preview.png)

3. Click Do Refactor to proceed with the changes.

Procedure: Resolve conflicts

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

![cl_refactoring_conflicts_dialog.png](https://resources.jetbrains.com/help/img/idea/2026.2/cl_refactoring_conflicts_dialog.png)

* 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. ![cl_refactoring_conflicts_toolwindow.png](https://resources.jetbrains.com/help/img/idea/2026.2/cl_refactoring_conflicts_toolwindow.png)

Procedure: Configure refactoring settings

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)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `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.

## The most popular refactorings supported in CLion

|  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)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))  | Makes sure that you do not delete files that are referenced in your source code.  |  [Safe delete](safe-delete.html)  |
| Copy | `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` (Xcode), `F5` (Visual Studio), `F5` (Visual Studio (macOS)), `F5` (ReSharper), `F5` (ReSharper (macOS)), `F5` (QtCreator), `F5` (QtCreator (macOS)), `F5` (NetBeans), `F5` (Eclipse), `F5` (Eclipse (macOS))  | Copies an element. |  [Copy](copy-refactoring.html)  |
| 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)), `⌘ ⌃ ⌥ M` (Xcode), `Ctrl+R, M` (Visual Studio), `⌘ R, M` (Visual Studio (macOS)), `Ctrl+Alt+M` (ReSharper), `⌘ ⌥ M` (ReSharper (macOS)), `Ctrl+Alt+M` (QtCreator), `⌘ ⌥ M` (QtCreator (macOS)), `Alt+Shift+M` (NetBeans), `Alt+Shift+M` (Eclipse), `⌘ ⌥ M` (Eclipse (macOS))  | These refactoring actions help you reduce the code duplication.  |  [Extract function](extract-method.html)  |
|  Introduce 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)), `⌘ ⌃ ⌥ V` (Xcode), `Ctrl+R, V` (Visual Studio), `⌘ R, V` (Visual Studio (macOS)), `Ctrl+Alt+V` (ReSharper), `⌘ ⌥ V` (ReSharper (macOS)), `Ctrl+Alt+V` (QtCreator), `⌘ ⌥ V` (QtCreator (macOS)), `Alt+Shift+V` (NetBeans), `Alt+Shift+L` (Eclipse), `⌘ ⌥ L` (Eclipse (macOS))  |   Declares a new variable and initializes it with the selected expression.   |  [Extract/Introduce variable](extract-variable.html)  |
| 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)), `⌘ ⌃ E` (Xcode), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `F2` (ReSharper), `F2` (ReSharper (macOS)), `Ctrl+Shift+R` (QtCreator), `⌘ ⌃ R` (QtCreator (macOS)), `Ctrl+R` (NetBeans), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))  | Renames an element. |  [Rename](rename-refactorings.html)  |
| 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)), `⌘ ⌥ N` (Xcode), `Ctrl+R, I` (Visual Studio), `⌘ R, I` (Visual Studio (macOS)), `Ctrl+Alt+N` (ReSharper), `⌘ ⌥ N` (ReSharper (macOS)), `Ctrl+Alt+N` (QtCreator), `⌘ ⌥ N` (QtCreator (macOS)), `Ctrl+Alt+N` (NetBeans), `Alt+Shift+I` (Eclipse), `⌘ ⌥ I` (Eclipse (macOS))  | Inlines an element. Acts as the opposite of extracting. |  [Inline](inline.html)  |
| Change signature |  `Ctrl+F6` (Windows), `⌘ F6` (macOS), `⌘ F6` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ S` (macOS System Shortcuts), `Ctrl+F6` (XWin), `Ctrl+F6` (GNOME), `Ctrl+6` (KDE), `Ctrl+F6` (Emacs), `Ctrl+F6` (Sublime Text), `Ctrl+F6` (Sublime Text (macOS)), `⌘ F6` (Xcode), `Ctrl+R, S` (Visual Studio), `⌘ R, S` (Visual Studio (macOS)), `Ctrl+F6` (ReSharper), `⌘ F6` (ReSharper (macOS)), `Ctrl+F6` (QtCreator), `⌘ F6` (QtCreator (macOS)), `Ctrl+F6` (NetBeans), `Alt+Shift+C` (Eclipse), `⌘ ⌥ C` (Eclipse (macOS))  | Changes the call signature of a method or class.  |  [Change signature](change-signature.html)  |

## See also

### External Links

[http://www.refactoring.com/](http://www.refactoring.com/)

### External Links

[JetBrains CLion Blog](http://blog.jetbrains.com/clion/)

