Example
| Before | After |
|---|---|
public class MyClass { // some code here } ... public void myMethod() { MyClass myClass = new MyClass(); } |
public class YourClass { // some code here } ... public void myMethod() { YourClass yourClass = new YourClass(); } |
- Select the item to be renamed.
- Choose on the main menu or on the context menu of the selection or press Shift+F6Shift F6.
-
In the Rename dialog box that opens, specify additional configuration settings:
- To have the changes applied to comments and strings, select the Search in comments and strings check box.
- When renaming a file, specify whether references should be renamed too.
- To have the changes applied to the text files (such as documentation, HTML, JSP and other files included in your project), select the Search for text occurrences check box.
Note
The set of controls and their names depend on the type of the symbol to be renamed.
- If you want
IntelliJ IDEA
to find and rename objects related to the renamed class, whose names contain the
changed string, check one or more of the following options:
- Rename variables to rename the variables of that class type.
- Rename inheritors to rename class inheritors.
- Rename bound forms to rename the GUI forms bound to the class.
Note
If you chose to rename any of the objects bound to the renamed class, IntelliJ IDEA searches for appropriate items and displays them in a sequence of dialogs, sorted by type. In each dialog you may select the items you want to change.
- Preview and apply changes.
Tip
Local variables, by default, are renamed in-place:

To be able to use the Rename dialog when renaming local variables, you should disable in-place refactoring in the editor settings.

