IntelliJ shortcuts

Here's a list of useful intelliJ shortcuts. You can also refer to the cheat sheet or the intelliJ website.

Commonly used shortcuts

Action Shortcut Remarks
Quick documentation lookup Ctrl + J -
View suggested parameters for a function (intellij tool tip) ⌘ + P -
Inspect element / contents of variables / symbols ⌘ + mouseover -
Find and select all occurrences in file Ctrl + ⌘ + G -
Postfix completion ⌘ + j to display postfix completion suggestions list( e.g. nn / null, notnull, try, for (this is a forEach shortcut), fori, forr (reverse for loop), synchronised). To see all postfix completion commands, type shift + ⌘ + a and search for ‘postfix completion’]
Indentation Tab (forward) and shift + tab (backward) -
Autofix indentation/formatting Alt + ⌘ + L Auto fix all indentation and formatting issues!!! To fix only a certain part, select the lines of the code (or the file or the folder) before running alt + ⌘ + L
Code Generator (awesome!!) ⌘ + N Select which method you want to generate: (e.g. Constructor, Getter / setter, equals() and hashCode(), toString, super, copyright, etc)
Generating Stub test, setUp and tearDown methods Ctrl + Enter To auto-generate a test, type Ctrl + Enter to bring up the generator menu, and select Test. A test will be generated, and you can just rename it accordingly. The same can be done for setUp and tearDown
Running tests Ctrl + Shift + F10 A dropdown menu will show and you can select which test or test class you want to run
Rerun last test Ctrl + F5 Very useful since we probably want to run the previously run test instead of running all tests every time
VCS and Git
VCS operations popup, searching for branches and annotation Ctrl + V see all commands relating to Git. You can click on the number (0-9) as a shortcut
Git commit ⌘ + K Click alt + ⌘ + z to revert a file
Git diff click on a file and click ⌘ + D -
Open terminal in intelliJ Alt + F12 -
Surround selected code with… (if..else, try..catch, for, synchronized, etc.) ⌘ + option + T -
Quick fix Alt + enter -
Search all commands Shift+⌘+A -
Search everything Shift+shift -
Move lines Shift + alt + up/down -
Move statements Shift + ⌘ + up/down -
Copy, cut paste ⌘ + C/X/V Works without selecting the whole line!
Duplicate line ⌘ + D -
Delete line ⌘ + delete -
Navigating to symbol / method Alt + ⌘ + O You can search for the method name, or the class.method(). E.g. both getName() and SCEL.getName() will work
Go to line+column ⌘ + G You can navigate by specifying the line and column
Switching between tabs/files ⌘ + E You can choose which file you wish to navigate to from the dropdown menu
Refactoring
Copy F5 -
Move F6 -
Safe Delete ⌘ + Delete -
Rename Shift + F6 -
Change Signature ⌘ + alt + F6 -
Inline Variable ⌘ + alt + N -
Extract Method ⌘ + alt + M -
Extract Variable ⌘ + alt + V -
Extract Field ⌘ + alt + F -
Extract Constant ⌘ + alt + C -
Extract Parameter ⌘ + alt + P -

results matching ""

    No results matching ""