Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 240
daiyue Avatar asked Dec 02 '14 12:12

daiyue


People also ask

How do you change variable name in IntelliJ all places?

Press Shift+F6 or from the main menu, select Refactor | Rename. next to the highlighted element. You can press Tab to open the context menu and select the additional rename options. If you want to see the Rename dialog with more options, click the More options link or press Shift+F6 .

How do I change multiple variables in IntelliJ?

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.

How do you change multiple variable names?

The problem you are facing can be solved by the process called Refactoring. Place the cursor inside a variable you want to rename and press Ctrl + R . Then type other name and editor will change all occurrences of that variable. Save this answer.


1 Answers

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.

like image 138
Insomniac631 Avatar answered Oct 06 '22 00:10

Insomniac631