16

How to press "Do refractor" button when you are trying to refractor some method in (PHP, Java..) code.

Steps:

  • Press ctrl+r to rename method
  • Change the name then u press enter
  • Then another panel shows with usages of this method and a "Do Refactor" button

Is there a way to press "Do Refactor" without using the mouse?

Corey Scott
  • 2,430
  • 3
  • 28
  • 33
Srneczek
  • 2,143
  • 1
  • 22
  • 26
  • Do you know the `⌘-shift-A` (or your non-Mac equivalent) shortcut? You can then type any command by name to execute it. – Greg Kopff Apr 13 '15 at 11:37
  • I have it on different shortcut but yest - it doesnt solve this issues - there are only "shortcut assignable actions" - arent there? – Srneczek Apr 13 '15 at 13:31

3 Answers3

23

IntelliJ tries to solve as many problems as possible using only your keyboard.

In your case, a panel showing a refactoring preview is really useful. You can use your arrow keys to navigate through this panel and exclude unwanted refactorings by pressing Del. To confirm the refactoring, just press Alt + D. The Do Refactor button has a shortcut underline on the D, that's why you don't even need to memorize this.

Regarding your second question (camel case navigating): you need to check the following setting:

Settings > Editor > General > Smart Keys > Use "CamelHumps" words

Now you can navigate within Strings using Ctrl + R/LArrow.

Btw: you can return to your editor anytime by pressing Esc.

And finally - you can execute almost any command by pressing Ctrl + Shift + A. Simply type the name of your command (like Rename) to execute it. So even without a shortcut, you don't need to use your mouse.

Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • 1. cool, I guess I remaped my keys and somehow disabled the alt+anything feature, so I even didnt know about it 2. I am aware of camel humps settings, but I turned it off since in many cases it can be kinda annoying. They should exlude this setting in renaming window since it doesnt make any sence NOT to use it there. – Srneczek Apr 13 '15 at 13:34
  • 1
    Thanks, it works also on the MacOS (as the `option`+`d` version). – Szymon Przedwojski Jul 12 '19 at 07:46
8

Every button has a letter underlined, if you press alt and this letter then it will do this action.

You can also move focus (which is by default on main button) using tab and shift+tab and use enter to validate your choice.

benzonico
  • 10,635
  • 5
  • 42
  • 50
0

There doesn't appear to be a macOS version of this. See this 2004(!) thread.

David Lord
  • 628
  • 10
  • 29