5 min read

Useful IntelliJ hotkeys and workflows on macOS

I do all of my development work in IntelliJ on Mac, and this is a collection of tips, tricks, and shortcuts I use to get the most out of it.

Hotkeys

Action Menu

⌘ + ⇧ + A activates the super-versatile Action Menu. Just type in whatever action you’re looking for, whether that’s commenting your code or popping open a terminal. This menu is extremely useful for when you forget a hotkey (as long as you don’t forget the hotkey for the action menu itself).

IntelliJ has a convention of ⌘ plus a number to pull up various IDE tabs. Here’s a list of them:

CommandIDE component
⌘ + 1Open Project tab
⌘ + 2Open Favorites tab
⌘ + 3Find
⌘ + 4Open Run tab
⌘ + 5Open Debugger
⌘ + 6Open Project ToDos
⌘ + 7Open Project Structure tab
⌘ + 9Open Version Control tab
⌥ + F12Open Terminal

(I’m not sure why ⌘ + 8 doesn’t seem to activate anything, at least on my machine as I’m writing this. It may be that I don’t have the feature activated that those correspond to.)

CommandFunction
⌘ + BJump to source (this can also be done by ⌘ + clicking on the code)
⌘ + NGo to class (On some keyboard layouts this is ⌘ + O)
⌘ + ⇧ + NGo to file (On some keyboard layouts this is ⌘ + ⇧ + O)
⌘ + ⌥ + ⇧ + NGo to symbol or method (On some keyboard layouts this is ⌘ + ⌥ + ⇧ + O)
⌥ + F7Find usages of code at cursor
⌃ + ⌥ + OOptimize imports. This removes any unused imports and consolidates multiple imports from the same packages based on a threshold (default 5, iirc)
⌃ + ⇧ + FFind in path
⇧ + ⌘ + VShow clipboard stack
⇧ + F12Show overview of current file, methods, etc.
⇧ + ⇧Search everywhere
⌘ + GGo to line number
⌘ + F1View description of error or warning, if there is one present
⌘ + F12Find members in current file. Lets you quickly jump to methods.
CommandFunction
⌘ + EGo to recent files
⌘ + ⇧ + EGo to recently edited files
⇧ + F4Externalize editor
⌘ + F4Close current file in editor
⌘ + ⇧ + F12Hide all windows and maximize current window

Editor keyboard shortcuts

CommandFunction
⌘ + ⇧ + ↵Complete statement. In Java, for example, this automatically adds semicolons on lines.
⌘ + JLive Templates. Basically code completion. Really handy for generating boilerplate.
⌘ + XCut line
⌘ + YDelete line
⌘ + DDuplicate line
⌘ + WIncremental selection. Expands the selection around the cursor.
⌘ + ⇧ + TGenerate a test/in a test class, go to class under test
⌘ + ⌥ + ZRevert changes
⌘ + ⇧ + ⌫Go to last edited location
⌘ + ⇧ + UToggle between upper and lower case

Debugger keyboard shortcuts

CommandFunction
⌘ + 5Open Debugger
⇧ + F10Run code without debugger
⇧ + F9Run code with debugger
⌘ + F8Set a breakpoint
F9Continue from breakpoint
F8Step over
⇧ + F8Step out of
F7Step into

Version control keyboard shortcuts

CommandFunction
⌘ + 9Open Version Control tab
⌘ + ⌥ + AAdd file to version control. Can be used from within a file or in the Version Control pane
⌘ + KCommit selected files
⌘ + ⌥ + ZRevert changes
⌘ + DShow diff
⌘ + ⇧ + UUnshelve changes

You can use the and keys to expand and collapse folders in the tree in the Project view.

Cycle through open files and tool windows

Ctrl + Tab lets you cycle through any processes you have open in the current session.

IntelliJ refers to this as the “Switcher” and it’s documented here.

Local history

Delete something on accident? Inadvertently get yourself into a pickle with git? Never fear, local history is your best friend. Get to it by going to VCS -> Local History -> Show History. It will show all changes made to all your files in chronological order, and you can revert back to any of them. You can also view local history for a file. Simply right-click the file in the editor window, then select Local History -> Show History.

UI

Show/hide the items along the edges of the IDE

Click the icon in the bottom left-hand corner of the window to toggle the visibility of the edge items, like projects, Maven, etc. I usually prefer these to be shown.

Variable highlighting

Clicking on a variable highlights it throughout a file.

← All posts