简体   繁体   中英

Keyboard shortcut for 'refactor' for IntelliJ IDEA

In Visual Studio (using IDEA key mapping), Ctrl + Shift + R brings up the 'Refactor' menu.

How do I do the same in IntelliJ?

On Windows.

ctrl + alt + shift + t = refactor this

in intelliJ IDEA version 11.0.2

If you press on CTRL + Shift + A and type in the action you want to perform, it also shows the shortcuts keys. This way you can learn shortcuts much easier.

在此处输入图片说明

The range of refactoring options in IntelliJ is fantastic, right click in your editor and hit R to see the entire menu. You'll soon want to just use the keyboard shortcuts though; some of my favourites are:

  • Shift + F6 : refactor a method or variable name
  • Ctrl + Shift + F6 : refactor a variable / field type
  • Ctrl + Alt + M : extract a method
  • Ctrl + Alt + V : introduce a variable

You'll find the main refactoring actions are bound to keys, rather than the entire menu being associated with a keyboard shortcut. The cheatsheet shipped with IntelliJ (Help > Default Keymap Reference) was invaluable when I was trying to get my head around everything that was possible. ( Available online too! ).

I think you can probably get the refactoring menu in Windows by hitting the Context key (next to the Right Ctrl) and then R whilst your cursor is in the editor window. Not sure if a dedicated binding exists - I'm pretty sure you can't set one.

Alt + R will pull down the menu. For instance, Alt + R , L will allow you to pull up a method.

Hm, just press ctrl+r - it does refractor pretty much anything? I switched keyboard shortcuts layout to Netbeans and tweaked it a little bit but I don't think it changed anything. True challange is "How to press DO REFRACTOR button in the usages window when you want to refractor some method used on several places WITHOUT using mouse".

If you are looking for a the default macOS keys ( provided you have default macOS set on IntelliJ), they are going to be -

fn+shift+f6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM