IntelliJ IDEA Cheat Sheet

Posted on Jun 22, 2017 (last modified May 8, 2021)

Keyboard shortcuts and various tips for IntelliJ IDEA. This document assumes IntelliJ on a Mac, using the Keymap setting for Mac OS X 10.5+ (in Preferences > Keymap). I know you can get all these through Help > Keymap Reference in IntelliJ, but I like to maintain my own list so that I can organize and search it the way I prefer, plus have a place to add my own additional notes.

Editing

Comment / uncomment selected textSelect block of text and then press CMD + /
Spread selection from cursor (to word, then line, etc.)ALT + up arrow or down arrow
Format selected codeCTRL + ALT + I
Format all codeALT + CMD + L
Autocomplete method parameter infoCMD + P (when cursor is in method signature)
Invoke a Surround Template (ex: surround a line with try/catch)OPTION + CMD + T
Complete a statementSHIFT + CMD + ENTER
Import Java PackageHover over the red text of the class missing a package and press: ALT + ENTER

Live Templates

Live templates can be found in Preferences > Editor > Live Templates. Learn them! To use a live template, enter its short text in the editor and then press tab to replace the short text with its template.

Navigation

Tool Windows and Dialogs

ProjectCMD + 1
Version ControlCMD + 9
PreferencesCMD + ,
BreakpointsSHIFT + COMMAND + F8
Recent FilesCMD + E
Search EverywhereSHIFT + SHIFT
Search ClassesCMD + O
Search SymbolsOPTION + CMD + O
Navigate back and forth through recent filesCMD + [ and CMD + ]
New file (where selection is in Project window)CMD + N Note: you can use slashes to create entire trees abc/def/ghi/jkl…
Hide all other windowsSHIFT + CMD + F12
Stretch pane right or leftSHIFT + CMD + left or right arrow
Clipboard HistorySHIFT + CMD + V
Method List (of the active editor file)CMD + F12
Navigation BarCMD + up arrow Note: This is particularly useful if you turn off the normal navigation bar in preferences to save UI space.
Action SearchSHIFT + CMD + A (try, for example, “RESTful Web Service”)
Version Control Quick ListCTRL + V
Quick Switch SettingsCTRL + ~
Quick DocumentationCTRL + J (and then again to pin it open at larger size).

TO DO items

Create a TO DO item

  • CMD + / to create a new comment line
  • Type TODO then whatever comment you want

View all TO DO items

  • View > Tool Windows > TODO or
  • CMD + 6

Increase IntelliJ IDE memory on a Mac

  • Help > Edit Custom VM Options…
  • Answer Yes to create the idea.vmoptions file. This will automatically create a copy of the .vmoptions file in the config folder and open a dialog to edit it.
  • I change -Xmx750m to -Xmx2048m

Tips

Following are some of the Tip of the Day items that appear when you first open IntelliJ.

Highlight usages of some variable
  • Use ⇧⌘F7 (Edit | Find | Highlight Usages in File) to quickly highlight usages of some variable in the current file.
  • Use ⌘G and ⇧⌘G keys to navigate through highlighted usages.
  • Press ⎋ to remove highlighting.
Optimize imports
  • Use Code | Optimize Imports to automatically optimize imports (remove unused imports, etc.). To access the corresponding settings, use File | Settings | Code Style | Imports.
Reformat code
  • Use Code | Reformat Code to reformat code according to your code style preferences (File | Settings | Code Style).

References