Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a keyboard shortcut for "Do Refactor" (Refactor Preview Pane) in IntelliJ IDE?

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?

like image 518
Srneczek Avatar asked Apr 13 '15 11:04

Srneczek


People also ask

How do I refactor in IntelliJ?

Invoke refactoringSelect an item to refactor. You can select a file/folder in the Project tool window or expression/symbol in the editor. Press Ctrl+Alt+Shift+T to open a list of refactorings that can be selected. Alternatively, you can use a keyboard shortcut for a specific refactoring.

How do I refactor a class name in IntelliJ?

You can right click the name of the variable/function and select refactoring > rename.

What is refactoring IDE?

Go Up to The Code Editor Index (IDE Tutorial) Refactoring is the process of improving your code without changing its external functionality. For example, you can turn a selected code fragment into a method by using the extract refactoring method.


2 Answers

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.

like image 68
Darek Kay Avatar answered Nov 10 '22 00:11

Darek Kay


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.

like image 28
benzonico Avatar answered Nov 09 '22 23:11

benzonico