[Java] [IntelliJ] Five shortcut settings that make operations convenient

4 minute read

For efficient programming, I think you will use an IDE that is easy for you to use.

I mainly develop in Java and used to love Eclipse before, but now I switched to IntelliJ. At first, it was unfamiliar and difficult to use, but now I can not let it go.

I will show you how to customize IntelliJ to make it easier to use.

This may not be a hint to those who have already customized it, but surprisingly many people around me take the time to operate with the default settings. Also, I think that you may notice a method that you can not think of yourself, so I hope you can refer to it.

What is IntelliJ

Let me briefly explain about IntelliJ.

IntteliJ is a Java IDE (Integrated Development Environment) provided by JetBrains. Open source Eclipse has been used in Java for many years and was in the de facto standard position, but it is said that it has broken down the stronghold of Eclipse.

IntelliJ has a Community version (free) and a Pro version (paid). Even the Community version has enough features, so I hope people who are using Eclipse will try it once.

By the way, PHP Storm, which is said to be the strongest IDE in PHP, is also a product of JetBrains.

Prerequisites for customization

As the premise of this article, I’m adding customizations based on the Eclipse keymap. The reason is that we simply want to unify the keymaps.

After all, the Java IDE is currently in a transitional period, moving from Eclipse to IntelliJ. If we change the scene, it may become an environment where only Eclipse can be used (it has become), and we don’t have time to get used to IDEs with different operability.

Therefore, we are taking measures to unify the default keymap and reduce problems. I would appreciate your understanding. So, I’ll duplicate the base settings first.

◆File ⇒ Settings

image.png

◆Left: Select the key map Middle: Select Eclipse Right: Duplicate

image.png

Customizing IntelliJ shortcuts

Let’s customize the main shortcut. The following five shortcuts are set this time.

  • Display in Explorer: “Ctrl + Shift + Q”
  • Rename: F2
  • Branch: “Ctrl+-“
  • Fetch: “Ctrl + ^”
  • Pull: “Ctrl+"

Display in Explorer: “Ctrl+Shift+Q”

Open the currently focused file or parent folder of the folder with Explorer. The original operation is [Right click] in the project on the left → [Show in Explorer].

image.png

File operations can basically be operated from IntelliJ, so it may be used infrequently, but setting it will be very convenient. You can set any shortcut, but this time it is set to “Ctrl + Shift + Q”.

Since it is the first one, I will also describe the registration method.

◆File ⇒ Settings

image.png

◆Key map ⇒ Search by “Explorer” image.png

◆ Right-click on the corresponding command ⇒ Add a keyboard shortcut image.png

◆ Enter shortcut ⇒ OK image.png

“Ctrl+Shift+Q” is now assigned to “Display in Explorer”. So You can change other shortcuts in the same way.

image.png

Rename: F2

Rename the entire project after changing the class name and file name. The original operation is “refactoring ⇒ rename”.

It’s not just a name change, it’s an excellent tool that automatically renames all files. Especially during development, it is used quite often, so make sure that you can operate it quickly. I wanted it to look the same as Explorer, so I assigned it to “F2”.

image.png

Branch: “Ctrl+-“

It is used to perform various branch-related operations such as checking and switching the branch of git. The original operation is “VCS ⇒ Git ⇒ branch”.

image.png

As you can see, it’s a troublesome operation, so let’s register it as a shortcut. I assigned it to “Ctrl+-“. The branch operation is now easy. Renovation work will also progress.

image.png

Fetch: “Ctrl + ^”

This is an operation to execute the “git fetch” command. The original operation is “VCS ⇒ Git ⇒ fetch”.

image.png

In IntelliJ, even if pull operation is performed on the IDE, the remote branch to be referenced may not be in the latest state, and this can be solved by fetching once. Fetch ⇒ pull will be used in a series of flows. Of course, do it before you check out.

image.png

Pull: “Ctrl+"

This is an operation to execute the “git pull” command. The original operation is “VCS⇒Git⇒Pull”.

image.png

Although pull is used in a few situations, if conflicts frequently occur in the early stages of development, it may be better to proceed without creating a branch. In this case, the local source is saved by stash or shelve, and fetch ⇒ pull is frequently used.

There is no problem in checking out with another name, but in IntelliJ, pulling can be executed more quickly, which leads to speedup.

image.png

Finally: customize IntelliJ to your liking

Introduced with a focus on customizing IntelliJ shortcuts. There are many operations related to git this time, and the benefit may be small if you do not use git, but I think it will be a hint for efficiency improvement.

Making keymap changes is very important. Even if each one is a small operation, it should be kept as short as possible if it is executed many times.

However, it is not possible to register all of them as shortcuts, so let’s actively register shortcuts focusing on the functions that I frequently use and operations that cause stress.

You can register a shortcut in 1 minute. Don’t lose more than a minute!