# Rename refactorings

> **TL;DR**
> Shortcut: `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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))
>
>
>
> Main menu: `Refactor | Rename`
>
>
>
> Context menu: `Rename`
>
>
>
> [General refactoring settings](code-editing.html): `Settings | Editor | Code Editing`
>
>
>
> In-place refactoring is available
>
>
>
> IntelliJ IDEA supports this refactoring for Java 14 code

Use the Rename refactoring to change names of symbols, files, directories,   packages, modules and all the references to them throughout code.

Renaming local variables or private methods can be done easily inline since only the limited scope is affected. Renaming classes or public methods could potentially impact a lot of files. Preview potential changes before you refactor.

> **Tip:**
> When you rename methods that are declared in interfaces, you can also review and rename their implementations as well. The refactoring changes are displayed on the Refactoring Preview tab in the Find tool window.

Procedure: Rename code in place with gutter icon

> **Note:**
> The rename process using a gutter icon does not apply to Java files. Renaming in Java files is implemented with an [inlay hint](#inplace_rename_inlay_hint).

1. In the editor start renaming a parameter, a method, or other   code element. IntelliJ IDEA will display ![the Rename the usages of icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.suggestedRefactoringBulb.svg) in the gutter.

2. Click the gutter icon or press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) and apply a suggestion.

![Rename inline](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rename_inline.png)

IntelliJ IDEA renames the code element and updates its usages accordingly.

![Rename refactoring result](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rename_result.png)

Procedure: Rename code in place with inlay hint

> **Note:**
> The inlay hint rename refactoring applies only to Java files. Other files may use a [gutter icon](#inplace_rename).

1. In the editor, find the code element you want to rename.

![Ij identify code element](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_identify_code_element.png)

2. Edit the text of the code element you want to rename, IntelliJ IDEA will display the Rename usages inlay hint.

![Ij rename usages inlay hint](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rename_usages_inlay_hint.png)

3. Select the inlay hint. If IntelliJ IDEA determines that some variables might also be renamed, the Rename Variables dialog opens. To confirm the rename refactoring, select OK.

![Ij rename variables dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rename_variables_dialog.png)

If IntelliJ IDEA doesn't identify any variables that might also be renamed, IntelliJ IDEA immediately renames the code element and updates its usages accordingly.

![Ij code element renamed](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_code_element_renamed.png)

Procedure: Rename a directory or a module

1. In the [Project tool window](project-tool-window.html) right-click a directory or a module that you want to rename.

2. From the context menu, select `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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))).

3. In the popup that opens, select what you want to rename. If you have a module with one content root, and it has the same name as your module, you can rename them both simultaneously.

![Select refactoring popup](https://resources.jetbrains.com.cn/help/img/idea/2026.2/select_refactoring_dialog.png)

4. In the Rename dialog that opens, type the new name, specify additional options and the scope of the refactoring, and click Refactor.

> **Note:**
> If you rename both module and directory at once, in the [Rename](rename-dialog-for-a-directory.html) dialog add the new name, check where to search for references and then click OK.

Procedure: Rename a package

1. In the [Project tool window](project-tool-window.html), click Project and select Packages from the list. IntelliJ IDEA lists all the packages in your project.

2. Right-click the package you want to rename and from the context menu, select `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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))).

If you have multiple directories that correspond to the package, or the package contains directories in the libraries that cannot be renamed, IntelliJ IDEA will display a warning. However, you can proceed with one of the offered options in the warning. IntelliJ IDEA opens the [Rename](rename-dialog-for-a-package.html) dialog where you can enter the new package name and click [Preview](refactoring-source-code.html#refactoring_preview) to see what directories and files will be affected before you decide to refactor. If you want to undo the changes you have made, 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` (NetBeans), `Ctrl+Z` (Visual Studio), `⌘ Z` (Visual Studio (macOS)), `Ctrl+Z` (Eclipse), `⌘ Z` (Eclipse (macOS)).

Procedure: Rename a code element

1. In the editor, select the element you want to rename. If you need to rename a file, select one in the Project tool window.

2. Press `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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS)) or right-click and select `Rename` from the context menu.

When you invoke the 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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS)) action, IntelliJ IDEA displays ![the Rename in comments and strings icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.codeInsight.inlayRenameInComments.svg) and ![the Rename in text occurrences icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.codeInsight.inlayRenameInNoCodeFiles.svg) next to the highlighted element.

![Rename variable](https://resources.jetbrains.com.cn/help/img/idea/2026.2/rename_var.png)

You can press `Ctrl+Alt+Shift+N` (Windows), `⌘ ⌥ O` (macOS), `⌘ ⌥ ⇧ N` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ O` (macOS System Shortcuts), `Ctrl+Alt+Shift+N` (XWin), `Ctrl+Alt+Shift+N` (GNOME), `Ctrl+Alt+Shift+N` (KDE), `Ctrl+Alt+Shift+N` (Emacs), `Ctrl+Shift+R` (Sublime Text), `⌘ ⇧ R` (Sublime Text (macOS)), `Ctrl+Alt+Shift+O` (NetBeans), `Ctrl+Alt+Shift+T` (Visual Studio), `⌘ ⌥ ⇧ T` (Visual Studio (macOS)), `Ctrl+Alt+Shift+N` (Eclipse), `⌘ ⌥ O` (Eclipse (macOS)) to open the context menu and select the additional rename options.

![Additional Rename options](https://resources.jetbrains.com.cn/help/img/idea/2026.2/additional_rename_options.png)

If you want to see the Rename dialog with more options, click the More options link or press `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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS)).

3. Open (`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` (NetBeans), `Ctrl+R, R` (Visual Studio), `⌘ R, R` (Visual Studio (macOS)), `Alt+Shift+R` (Eclipse), `⇧ F6` (Eclipse (macOS))) the [Rename](rename-dialogs.html) dialog. Enter a new name of the element to enable the Preview and Refactor buttons.

![The Rename dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/rename_dialog.png)

You can specify additional options. For example, specify where to search for element occurrences, or what else to rename. You can also specify a scope for the refactoring.

4. Click Preview to see the potential changes or click Refactor.

When you click Preview, IntelliJ IDEA opens the [Find](find-tool-window.html) tool window with the results of found usages where you can check the results and confirm the refactoring (Do Refactor).

Next time you invoke the Rename refactoring, IntelliJ IDEA remembers the options you have specified inside the Rename dialog.

> **Note:**
> You cannot rename the `.idea` project directory since IntelliJ IDEA always reads the project files from the directory with that exact name.

## Examples

Let's rename a class `MyClass`.

| Before | After |
| --- | --- |
|     ```JAVA public class MyClass {     // some code here }      public void myMethod() {         MyClass myClass = new MyClass();     } ```    |     ```JAVA public class YourClass {     // some code here }      public void myMethod() {         YourClass yourClass = new YourClass();     } ```    |

> **Tip:**
> If you need to edit variables rather than to change them completely, go to `Settings | Editor | Code Editing` and clear the Preselect current symbol name for Rename refactoring checkbox located in the Refactorings section.

## See also

### Reference

[Rename dialogs](rename-dialogs.html) [Find tool window](find-tool-window.html)

