Codementor Events

6 Time-Saving Hotkeys that Every Developer Should Learn and Master

Published Dec 17, 2019
6 Time-Saving Hotkeys that Every Developer Should Learn and Master

Navigating a codebase with the least effort and time possible is a key requirement for understanding codebases quickly and deeply. Hotkeys help us quickly navigate by allowing developers to issue high volume commands to the IDE without the need for switching back and forth between the mouse and keyboard.

Not all hotkeys are equal. Some get used way more than others and hence, are more valuable to learn. Others will be specific to your personal working style.

1. The Hotkey Cheatsheet - Learn Them as You Work

One of the most important hotkeys you should learn when starting out with an IDE, is the hotkey for looking up other hotkeys.

Search Keyboard Shortcuts

Visual Studio Code IntelliJ IDEs
PC/Linux Ctrl K Ctrl S Ctrl Shift A
Mac ⌘K ⌘S ⌘⇧A

Mastering this hotkey will let you search the IDE instantly for other hotkeys with you need at the very moment. Learning hotkeys is an upfront investment and mentally taxing because you will repetivitly lookup the same information every time you need to use it. Having THIS hotkey handly makes learning other hotkeys faster until they become muscle memory.

2. Jump to a Specific File

Jumping between files is really important when trying to understand the relationship amonst various code blocks in different file locations. The navigation speed is important because you need to juggle various bits of info in your working memory to make sense of large chunks of spread out code.

Go to File

Visual Code IntelliJ IDEs
PC/Linux Ctrl E Ctrl Shift N
Mac ⌘P ⌘⇧O

Searching and selecting from the list of recently visited files is an great extention to this hotkey.

Search and Select Recently Visited File

Visual Code IntelliJ IDEs
PC/Linux Ctrl E Ctrl E
Mac ⌘P ⌘E

3. Go Backward & Forward in Navigation History

In the browser, hitting the back button can be a real time saver. It's more efficient than re-entering the URL of the recently visited page. We can click on a link, read, and hit back to return to original context.

Similarily, when trying to understand codebases, we can jump all over the codebase looking at different various layers of abstractions and need the ability to back/foward quickly. If we conciously start thinking about file names and their locations, we interfere our working memory that needs to process the code's functionality. Thus, jumping back and forward between locations impulsively is important.

Go Back

Visual Code IntelliJ IDEs
PC/Linux Ctrl Alt - Alt ←
Mac ⌃- ⌘[

Go Forward

Visual Code IntelliJ IDEs
PC/Linux Ctrl Shift - Alt →
Mac ⌃⇧- ⌘]

4. Code Folding & Expanding

When you open a file with lots of unfamiliar code, it can be intimidiating to start reading. You will tend to read code without understanding the big picture right away and this adds extra time for comprehension. Reading and understanding other people's code quickly is one of the most important skills a developer needs for success.

Code folding and expanding is one of the best ways of managing the complexity while navigating code. When we encounter a file with multiple levels of code blocks, our first instinct should be to collapse or fold ALL the code blocks in the file. This enables use to only see names of variables, classes, functions, methods at the highest level. If the code is clean, we can already begin assuming the roles of each high level construct and unfold each region selectively when were interested in the implementation detail.

Fold All

Visual Code IntelliJ IDEs
PC/Linux Ctrl K Ctrl 0 Ctrl Shift -
Mac ⌘K ⌘0 ⌘⇧-

Unfold Region/Code Block

Visual Code IntelliJ IDEs
PC/Linux Ctrl Shift ] Ctrl +
Mac ⌥⌘] ⌘+

5. Go to Definition

When you come across an applied function or an unfamiliar variable, it can be helpful to see how it's derived. This helps understand the intention and the meaning behind the written code. This task is so repetitive, veteran developers have a muscle memory for this hotkey.

Go To Definition

Visual Code IntelliJ IDEs
PC/Linux F12 Ctrl B
Mac F12 ⌘B

Sometimes you need to see the folder structure to get a better feel of the project's organization. You may also not know the exact file you're looking for but have a good sence of its location or want to browse in a particular area before committing it to the editor. For this, jumping to the explorer and searching is the best way to go.

These days IDEs allow you to start searching for the file/directory by directly typing terms while focusing on the explorer. This highlights all the matching file/directories, and allows you to use the up/down arrow keys to bounce between the narrowed results. This is very helpful when you don't want to mentally process a long list of potential options from the search results.

Jump to Explorer and Start Typing

Visual Code IntelliJ IDEs
PC/Linux Ctrl Shift E Alt 1
Mac ⌘⇧E ⌘1

Conclusion

There are many hotkeys you can potentially learn but learning more than a handful simultaneously is very difficult. It's helpful to pick the most practical ones and practice them until they become muscle memory. Then, add more to your arsenel with time. This helps internalize them more deeply, which will ultimately help you navigate code with speed. With superior navigation speed, you will be able to sustain more info in your working memory and will learn the inner workings of the code much faster.

Discover and read more posts from Rajjeet Phull
get started