My Favourite IntelliJ Know-Hows

Luka Giorgadze
Javarevisited
Published in
4 min readJan 3, 2021
Photo by Juan Gomez on Unsplash

IntelliJ IDEA is the most popular editor within the JVM community. It is by far my personal favorite and I’ve been using it for many years. In this article, I want to share what helps me to get the most out of IntelliJ in my daily work.

Disclaimer: your shortcuts may differ based on the keymap you’re using — mine is ‘IntelliJ IDEA Classic keymap’ with some customizations.

Re-wire tool windows shortcuts

IntelliJ provides a lot of useful tool windows that allow you to get insights into the project and access/run your whole project ecosystem. I find the default tool windows shortcuts assignment quite good, but I quickly realized that some of them I never used. Therefore I reassigned them:

‘⌘ + 2’ from Favourites to Databases

This one was quite straightforward — I often need to look into different databases, but never actually used the Favourites before… until recently, at least — now I save.http scratch files in Favourites with the HTTP requests that I want to keep, without checking them into the VCS.

‘⌘ + 6’ from Problems to Terminal

The terminal is a must for a software developer, and having a shortcut for it reduces the time I need to switch to it. I’m a big proponent of as few cognitive switches as possible, so having a possibility to access the terminal in my IDE helps me achieve that.

`⌘ + 7` from Structure to Git branches

The projects I work in have a lot of short-lived branches, therefore naturally, there is a lot of switching between branches. My initial approach was to:

  • Switch to terminal
  • Fetch from origin
  • List the branches (usually, you don’t know the branch name by heart)
  • Copy the branch name
  • Checkout the branch (possibly pull the latest changes as well)
  • Switch back to IDE

Having to switch, copy, run different commands, switch again was annoying. I love the VCS plugin in IntelliJ, but its option of having the ‘Git:branch_name’ at the bottom right corner did not appeal to me either. It was time for some customization!

Re-wiring the ⌘+7 shortcut to open the branches gives me an extremely quick overview of all branches with a great filter without having to switch to another tool. I also placed the branches pop-up in the middle of my screen. As a habit, I hit ⌘+T to pull the latest changes after I checkout a branch.

This is also a convenient way to create a new branch:

Quickly access the recently viewed code

IntelliJ memorizes all the code places you’ve visited in the current session. This is extremely useful when you’re jumping from class to class (or place to place), especially in an unfamiliar project.

Use ⌘+E to access the recent files:

And ⌘+⇧+E to access recent locations:

You can configure how many files/locations IntelliJ memorises by going to Preferences — Editor — General — Limits.

In case you want to mark specific code places persistently, try ‘Bookmarks’ (F10 on the line you want to bookmark).

Speed up with multiple cursors (different variations)

Code constantly changes and being able to refactor it quickly is always handy. When working with text changes (for example, editing the same mock verification in all tests within a test class) I’ve been using the replace functionality (⌘+R) quite a bit, but I was always lacking code completion in the replacement input area. ⌘+control+G solves that for me as it selects and places a cursor for all exact matches of the element on which your cursor is standing now, effectively allowing me to edit all of the occurrences at once:

For finer grained control I use control+G, which adds a cursor to the next occurrence only:

You can also place additional cursors in arbitrary places with ⌥+⇧+click (alt/option+shift+click):

Trace down method’s call stack with Call Hierarchy

Let’s say we have a project with quite common server layer architecture and we want to trace which API invocations result in a call to a certain repository method. Before I learnt about Call Hierarchy , I would find all usages of the repository method, pin that tab, and then find usages of the service methods that call that repository method. Complicated, right? With Call Hierarchy (control +⌥+H), IntelliJ does that for you and even allows you to filter further:

I hope you will find these tips useful!

--

--

Luka Giorgadze
Javarevisited

Developing software by day, sharing my experience by night (or vice versa)