Useful Shortcuts
Compile and Run
Make project (compile modifed and dependent)
Windows: Ctrl + F9
OS X / macOS: Cmd + F9
Compile selected file, package or module
This is useful to know, as when debugging this shortcut can be used to quickly reload / hotswap classes.
Windows: Ctrl + Shift + F9
OS X / macOS: Cmd + Shift + F9
Select configuration and run
Windows: Alt + Shift + F10
OS X / macOS: Option + Shift + F10
Select configuration and debug
Windows: Alt + Shift + F9
OS X / macOS: Option + Shift + F9
Run
Shift + F10
Debug
Shift + F9
Run context configuration from editor
Windows: Ctrl + Shift + F10
OS X / macOS: Cmd + Shift + F10
Code Completion
Basic code completion (the name of any class, method or variable)
Windows: Ctrl + Space
OS X / macOS: Cmd + Space
Smart code completion (filters the list of methods and variables by expected type)
Windows: Ctrl + Shift + Space
OS X / macOS: Cmd + Shift + Space
Overwriting code with a suggestion
Tab
Adding code from a completion suggestion
Enter
Search/Replace
Search everywhere
Double Shift
Find
Windows / Linux: Ctrl + F
OS X / macOS: Cmd + F
Find next
F3
Find previous
Shift + F3
Replace
Windows / Linux: Ctrl + R
OS X / macOS: Cmd + R
Find in path
Windows / Linux: Ctrl + Shift + F
OS X / macOS: Cmd + Shift + F
Replace in path
Windows / Linux: Ctrl + Shift + R
OS X / macOS: Cmd + Shift + R
Refactoring
Copy
F5
Move
F6
Safe delete
Windows / Linux: Alt + Delete
OS X / macOS: Cmd + Delete
Note that the Delete key on OS X / macOS is the equivalent of the Backspace key on other operating systems.
Rename
Shift+ F6
Extract Method
Windows / Linux: Ctrl + Alt + M
OS X / macOS: Cmd + Option + M
Extract Field
Windows / Linux: Ctrl + Alt + F
OS X / macOS: Cmd + Option + F
Extract Variable
Windows / Linux: Ctrl + Alt + V
OS X / macOS: Cmd + Option + V
Extract Constant
Windows / Linux: Ctrl + Alt + C
OS X / macOS: Cmd + Option + C
Extract Parameter
Windows / Linux: Ctrl + Alt + P
OS X / macOS: Cmd + Option + P
Other
Surround with
Surrounds a code block with an if
, for
, <editor-fold ...>
and more.
Windows / Linux: Ctrl + Alt + T
OS X / macOS: Cmd + Option + T
Basic navigation
Go to editor (from tool window)
Esc
Switching focus to corresponding tool window
Windows: Alt + <tool window number>
OS X / macOS: Cmd + <tool window number>
For example switching focus to the project window
Windows: Alt + 1
OS X / macOS: Cmd + 1
Recent files popup
Windows: Ctrl + E
OS X / macOS: Cmd + E
Find Action
Windows: Ctrl + Shift + A
OS X / macOS: Cmd + Shift + A
Navigate to
-
File :
-
Windows: Ctrl + Shift + N
-
OS X / macOS: Cmd + Shift + N
-
-
Class :
-
Windows: Ctrl + N
-
OS X / macOS: Cmd + N
-
-
Symbol (class/method/variable/constant name) :
-
Windows: Ctrl + Alt + Shift + N
-
OS X / macOS: Cmd + Option + Shift + N
Note that you can use class name to narrow down the method/variable/constant search, for example to find symbol
usersCollection
in classUserDAO
type:UserDAO.usersCollection
-
-
Everywhere :
-
Windows: Shift + Shift
-
OS X / macOS: Shift + Shift
-
To search for something that has multiple words, e.g., InetAddressCachePolicy
you can just type InAddCacPo
or something similar that contains parts of words in the whole name.
Go to line number
Windows: Ctrl + G
OS X / macOS: Cmd + L
Go back to last edit location
Windows: Ctrl + Shift + Backspace
OS X / macOS: Cmd + Shift + Backspace
Usage Search
Find usages / Find usages in file
Windows / Linux: Alt + F7 / Ctrl + F7
OS X / macOS: Option + F7 / Ctrl + F7
Highlight usages in file
Windows / Linux: Ctrl + Shift + F7
OS X / macOS: Cmd + Shift + F7
Show usages
Windows / Linux: Ctrl + Alt + F7
OS X / macOS: Cmd + Option + F7
Show Method Parameters
Windows / Linux: Ctrl + P
OS X / macOS: Cmd + P
Shows what parameters a method and all of its overloads accepts.
Selection
Selection with increasing scope
This comes handy when you want to select a block to extract a variable / method etc, no need to do a precise bracket matching, just put the caret somewhere in the statement and keep doing this
Windows: Ctrl + W
OS X / macOS: Cmd + W
Selection with decreasing scope
Windows: Ctrl + Shift + W
OS X / macOS: Cmd + Shift + W
This feature is also very useful when editing / playing with json documents in your IDE.
Vertical selection
Press and hold
Windows: Alt
OS X / macOS: Opt
and select normally using mouse / trackpad (the way you select a word in a row etc)
This is how it should look like
Multiple carets
Press and hold
Windows: Alt + Shift
OS X / macOS: Opt + Shift
and click where all you want to put a caret. You can choose to put multiple carets in a single line or across lines at different positions.
Now you can perform all operations that you would have been able to perform on a single selected word (hold Ctrl (windows) or option (mac OS) and use Left or Right keys to jump across words) and all those will affect all caret positions.
You can even cut / paste multiple selections from one place to another.
Having multiple carets is very usefult when you want to change the structure of text across many lines / many positions in same line.
Selecting duplicate occurences
Select some text and press
Windows: Alt + J
OS X / macOS: ctrl + G
to select the next occurance of the same text.
You get one caret at each of the selected occurrence that could be used to change each occurrence simultaneously.
E.g., I’ve tried to put an example in this gif, hope it helps