daiyue
daiyue

Reputation: 7448

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.

Upvotes: 20

Views: 56428

Answers (3)

Ankush kumar
Ankush kumar

Reputation: 61

Select your variable by right click > select refactor > rename

And rest all will be taken care by ide itself

enter image description here

Upvotes: 0

Sashini Hettiarachchi
Sashini Hettiarachchi

Reputation: 1708

Steps:

1: Put the cursor on the variable ex:

enter image description here

  1. Press shift+f6
  2. Enter the name you want in the appeared dialogue box

ex:

enter image description here

  1. Hit the Refactor button

Upvotes: 1

Insomniac631
Insomniac631

Reputation: 1088

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.

Upvotes: 47

Related Questions