Skip to content

Instantly share code, notes, and snippets.

@mcouthon
Last active May 13, 2019 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcouthon/0ebc4c94b5e9be32d6f7399433aa7831 to your computer and use it in GitHub Desktop.
Save mcouthon/0ebc4c94b5e9be32d6f7399433aa7831 to your computer and use it in GitHub Desktop.

JetBrains Shortcuts

Prerequisites: install jetbrains toolbox - use it to install IntelliJ (need ultimate edition for remote debugging; requires a license)

IntelliJ Community vs Ultimate

Full comparison. The main advantages of Ultimate:

  • Has all the functionality of DataGrip (SQL)
  • Has plugins for Ruby, Go, PHP, Node.js, Angular, React, and more
  • Supports Coffee/Type/Javascript
  • Settings sync via JetBrains account

All shortcuts here are from my personal keymap, that was adapted from the Mac OS X 10.5+ keymap. Search for the Action name in your own keymap (Preferences --> Keymap).

For shortcuts, option == alt in Mac (it's the Windows ⊞ key on most non-Mac keyboards. The order of the modifier keys is -> ctrl option cmd.

Search

Command Action Notes
cmd + shift + a Find action Fuzzy search
cmd + shift + f Find in path Fuzzy + regex + limit scope (default is everything)
cmd + enter Open in Find window Open/close window with cmd + 3
shift * 2 Find anything Fuzzy search
cmd + e Recent files List of recently closed files
cmd + e + e Recently changed files List of recently edited files
cmd + shift + e Recently locations Recently edited locations in files

Navigation

Between parts of the IDE

Command Action Notes
ctrl + tab Switcher Learn the shortcuts
cmd + number/letter Open/close tool window See full list in the Switcher
shift + esc Hide active tool window Needs to be in focus
option + F1 -> enter Scroll to file in project browser Current file in focus

In code

Command Action Notes
cmd + b Go to declaration Cursor on function usage
cmd + b Usages quick list Cursor on function declaration
cmd + F7 Find usages Cursor on function declaration/usage
cmd + F12 File Structure Fuzzy search works here
cmd + shift + left Navigate back In same file, or different files
cmd + shift + right Navigate forward In same file, or different files
ctrl + option + down Go to next usage Cursor on code element
ctrl + option + up Go to previous usage Cursor on code element
cmd + F3 Find word at caret Will select the word after the caret
F3 Find next word After cmd + F3
shift + F3 Find previous word After cmd + F3

Editing

Multiple selection + editing

Command Action Notes
cmd + d/j Add selection for Next Occurrence After selecting a word
cmd + shift + d/j Unselect Occurrence
cmd + shift + i Column selection mode Multiple cursors

Refactoring

Command Action Notes
shift + F6 Refactor --> Rename Cursor on code element (e.g. var/function)
F6 Refactor --> Move Cursor on code element (e.g. method)
cmd + option + t Surround with Opens a list of options
cmd + option + v Extract --> Variable After selecting a piece of code

Folding elements

Command Action Notes
cmd + shift + + Expand all
cmd + shift + - Collapse all
cmd + + Expand block
cmd + - Collapse block
cmd + option + + Expand recursively Completely expand a single block

Tip

Surround parts of code with custom regions to help with expanding/collapsing large files (cmd + option + t -> region..endregion Comments).

Debugging

Run/Debug code

Command Action Notes
ctrl + shift + r Run current file Creates a Run/Debug Configuration
ctrl + shift + F9 Debug current file Creates a Run/Debug Configuration
cmd + F10 Edit Run/Debug configurations
shift + F10 Run with current configurations With currently selected config
shift + F9 Debug with current configurations With currently selected config
cmd + 4 See Run output Only after first time
cmd + 5 See Debug output Only after first time

During debug

Command Action Notes
F7 Step into
F8 Step over
shift + F8 Step out Runs until the end of current block
F9 Resume run Runs until next breakpoint
option + F9 Run to cursor Runs until the line with the cursor
cmd + F8 Set breakpoint on current line
cmd + F2 Stop debug/run
option + F8 Evaluate expression Currently selected in editor

Debug extras

  • Navigate debug stack
  • Watch variables during debug
  • Conditional breakpoints

Remote debugging (in Python)

  • Install pydevd (where the code runs!) with pip install pydevd
  • Create remote debugger in PyCharm/Intellij
    • Go to configurations cmd + F10
    • New configuration cmd + N
    • Choose "Python Remote Debug"
    • Choose the local IP as it would be accessible from the remote code
  • Add a breakpoint in the remote code by adding:
import pydevd; pydevd.settrace('<LOCAL_IP>', port=53100, stdoutToServer=True, stderrToServer=True, suspend=True)
  • Start the remote debugger in PyCharm/Intellij
  • Run the remote code

Appearance

  • Theme - install via a plugin (e.g. Material Theme UI )
  • Color scheme - import from a file, from a plugin + customize!
    • Get mine here!
    • Browse other ones here.
  • Font - my favorite is Ayuthaya
  • Presentation mode.

Plugins

Language plugins

Other plugins

VCS (GitHub)

Command Action Notes
ctrl + k Commit changes Opens window with all the changes
ctrl + shift + k Push commits Shows all relevant repos
ctrl + d Show diff When in commit window and have file selected
F7 Next diff When showing diffs
shift + F7 Previous diff When showing diffs
No default shortcut Resolve conflicts Diff view during merge conflicts
cmd + alt + z Revert changes Revert changes to latest from version control

Other

  • Syncing settings (manual vs account vs GitHub repo)
  • Editing KeyMap
  • Project settings (modules/sdks/dependencies)
  • DB settings
  • Scratches
  • Clipboard manager - cmd + shift + v
@alexxv
Copy link

alexxv commented Apr 28, 2019

couple of suggestions I think might be useful:
cmd + shift + backspace - go to last edited location
cmd + e + e - recently changed files
cmd + shift + e - recent locations (new feature)
cmd + alt + z - revert to code block/file to latest from version control

Also, if you get used to navigate files using cmd + e, cmd + e + e, cmd + alt + arrows you might want to switch off tabs completely

@mcouthon
Copy link
Author

Thanks @alexxv! I incorporated some of those in the file.

@ran-z
Copy link

ran-z commented Apr 29, 2019

A few more random ones you might find useful:

cmd + shift + up/down - move code section (e.g. function) above/below same-scope element (e.g. reverse order of functions in file)
cmd + H - hierarchy of classes (mostly useful in java/kotlin)

cmd + F12 which you've mentioned is AFAIK "find method" in Java; you also have cmd + N for finding a class, and cmd + shift + N for finding a file, personally to navigate I mostly use these two.

Also might worth mentioning some various code insertion hotkeys (getters, overrides, ..)
Also, for the remote debug statement --> I have it under a snippet, so basically when I write "debug" then click Tab it just autocompletes it, makes things simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment