These Shortcuts Made Me 3x Faster
Forcing myself not to use the mouse made me 3x faster in everything I do.
A couple of years ago, an experienced engineer advised me to avoid using the mouse as much as possible. Whenever I moved my hand to the mouse, I asked myself whether it was necessary or if I could use a keyboard shortcut instead.
Following his advice over the past few years, I have become very efficient in using IntelliJ IDEA, the application I will likely use the most for the rest of my career. In this article, we will cover a few shortcuts that I use daily.
Even though I use IntelliJ IDEA, I am confident that these shortcuts are also available in VSCode.
Why Should You Care About Using Shortcuts?
The answer is simple: efficiency. As a software engineer, you will spend most of your time using an IDE. Knowing all the techniques to make you faster will save you seconds every day, which will accumulate to days or even months over time. So, let’s dive into it.
Command + W: Extend Selection
One of the shortcuts I use the most is “Extend Selection.” Each time you press the shortcut, IntelliJ IDEA will expand the selection to include a larger syntactic entity. It intelligently selects progressively larger code block.
As you can see in the GIF above, the cursor always stays in the same position as I press Command + W
consecutively, and with each press, more code is selected, demonstrating how the selection expands to include larger code blocks.
Command + Arrow Up/Down: Next/Previous Change
I often like to jump to changes that I made in a file (based on the Git diffs). This allows me to quickly navigate through a file and find the parts that I have been working on.
In the GIF above, you can see how I jump between two changes (based on Git diff) in the file.
Command + \: Split Right
In many cases, I like to open a second editor view on the right to view a different file.
To navigate seamlessly between multiple editors, I use a few shortcuts.
Command + \
: Open an editor to the rightCommand + E
: Open an overview of the most recent files, allowing you to open another file in the right editorCommand + Option + Right Arrow/Left Arrow
: Jump between the left and right editor with the cursorCommand + Option + \
: Close the right editor
Command + K: Find Action
In IntelliJ IDEA, I frequently use the “Find Action” shortcut. This allows me to perform various tasks in the IDE efficiently. I often use it for simple Git navigation tasks such as:
Creating new branches
Switching branches
Stashing/Shelving changes
Committing changes
While this may not be the most sophisticated way to use Git, it is fast and efficient using IntelliJ IDEA’s built-in capabilities.
In the GIF above, I do the following:
Command + K
: To find an actionType “branches” and hit Enter
Navigate to the
main
branch and hit EnterIn the extended pop-up to the right, select “New branch from main” and hit Enter
Type in the branch name and hit Enter
Another action I use frequently is shelving my current changes. This is similar to a Git stash but uses IntelliJ’s internal UI. It has some benefits over using Git stash, such as showing the diff view (changes) when unshelving.
In the GIF above:
I make changes to a file
Command + K
: Start typing: “Shelve changes”Now the file has the initial state again
I unshelve my changes again.
Creating new file
A combination of shortcuts that I use frequently allows me to create a new file at the same directory as the current file visible in the editor.
In the GIF above, you can see:
Option + F1
: Open the current file in the Project View on the left.Control + Enter
: Opens a pop-up showing a list of entities I can create. I hit Enter again to create a plain file and name it “newfile.tsx”. Then I hit Enter again when asked whether the file should be tracked by Git.
Command + Option + M: Extract Method
In the GIF above, you see me highlighting two lines of code and extracting these lines into a function. The function signature is automatically generated with the correct types.
Command + T: Toggle Terminal
Instead of switching contexts to different applications, such as with Command + Tab
, I prefer doing everything within my IDE. Therefore, I toggle the Terminal with Command + T
.
Increased Key Repeat
This is technically not a shortcut, but it allows me to navigate through source code significantly faster by increasing the key repeat.
In the GIF above, I navigate up/down/left/right through the file.
I highly recommend the video by Hadi Hariri, where he showcases various tips and tricks for IntelliJ IDEA. His insights have been incredibly valuable in improving my efficiency.
What shortcuts do you use the most? I would love to know.