Intellij IDEA: Make refactor > Rename not select the whole word
Asked Answered
M

4

28

When I press my shortcut to rename a variable (precisely it's the "Main menu" > "Refactor" > "Rename..." shortcut), the entire word is selected.

Is it possible to change the behavior so that simply the refactoring is activated and the cursor stays in position (it already does, this is fine) and that I can directly add or remove a character?

Right now, if I have a variable "myVarible" and I put my cursor between "i" and "b" to add the "a", press the shortcut, and type an "a", my entire variable becomes an "a", as the entire word was selected by the shortcut.

In Eclipse this seems to be the default behavior already, and I liked it much better. How can I change this in Intellij?

Metic answered 26/4, 2017 at 8:44 Comment(0)
C
38

You can do this by going to Settings -> General -> Refactoring and just deselect "Preselect old name" or just type Refactor in search box in settings so it will automatically go on above menu.

Cupped answered 26/4, 2017 at 9:23 Comment(3)
Perfect, exactly what I searched for :) Thank you!Metic
In the current version the option is under Settings -> Editor -> General in the sub-section Refactorings.Nickelic
In the current version the option is under Settings -> Editor -> Code Editing in the sub-section Refactorings.Dianetics
E
6

From IntelliJ 2018.2.6, the checkbox to disable is still "Preselect old name".
That is located in :

"Settings" menu
-> "Editor" section
   -> "General" subsection 
   -> "Refactorings" part

You can also just enter "refactorings" in the search box to find it.

disable preselect old name

Effluent answered 23/4, 2019 at 16:51 Comment(0)
S
4

Origin answer

Aaaand it moved again!

It's probably the best to just search for Refactorings or Preselect old name, as it might move again in the future.

In my version 2020.1.2 it is under

Settings -> Editor -> Code Editing -> Refactoring

enter image description here

Update Version 2023(.1)

JetBrain can't decide where to put and how to name this feature.

Since my origin answer it was renamed to "Preselect current symbol name for Rename Refactoring" and it moved to:

Settings -> Editor -> Code Editing

Saltandpepper answered 18/6, 2020 at 13:26 Comment(0)
U
1

It has changed name since the other answers, in 2021.2.3, It's still under Settings -> Editor -> Code Editing -> Refactorings however it's now named Preselect current symbol name for Rename refactoring.

Ultrasonic answered 4/11, 2021 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.