'IntelliJ replace variable names in multiple lines
I am wondering is there a shortcut that can replace a variable name with a new name on multiple lines in the current Java
file for IntelliJ
. Is it just simply doing a find and replace operation, but it can't really solve the problem obviously.
Solution 1:[1]
Try to set cursor on variable and use shortcut Shift-F6 - after that there are dialog frame for change name of variable and it changes all occurences of variable to setted name.
Also, you can use shortcut Ctrl-Shift-R for replacing any word in project, it is useful if you working with huge project or your variable appears in config files.
Solution 2:[2]
Steps:
1: Put the cursor on the variable ex:
- Press
shift+f6
- Enter the name you want in the appeared dialogue box
ex:
- Hit the Refactor button
Solution 3:[3]
Select your variable by right click > select refactor > rename
And rest all will be taken care by ide itself
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Sashini Hettiarachchi |
Solution 3 | Ankush kumar |