This article contains affiliate links. See my affiliate disclosure for more information.



How much time do you spend moving your hand between your keyboard and mouse?

One estimate puts the number at sixteen minutes a day. Eight whole days every year! Although the estimate isn't scientific, I don't think it's far-fetched. I'd guess that the number is even higher for coders. Keyboard shortcuts are essential for developers. There's no shortage of articles about shortcuts, but few provide any tips for practicing them.

Here are five of my most-used VS Code shortcuts and how I practice them to make them stick.

✉️
This article was originally published in my Curious About Code newsletter. Never miss an issue. Subscribe here →

#1 Navigate Words, Not Characters

Move your cursor to a new "word" on the current line without using your mouse and without moving character-by-character.

macOS Option+
Option+
Linux Ctrl+
Ctrl+
Windows Ctrl+
Ctrl+

Here's what it looks like in action:

Combine this with shortcuts to move your cursor to the beginning or end of a line for faster navigation. (macOS: Cmd+ and Cmd+; Windows: Home and End)

What Is a "Word?"

Generally speaking, words are separated by spaces and underscores.

Commas, periods, and other punctuation are often ignored. However, VS Code treats operators such as != and && as words and skips over nested braces to the next identifier or operator.

How To Practice It

⏱ Time: 1–2 minutes
🗓 Frequency: Twice a day for at least five days

Open any file in any codebase. Pick a line and move your cursor to somewhere within the line. Next, pick a "word" in the line and use the shortcut to move your cursor to it. Repeat this with different lines and different "words."



#2 Copy And Paste In a Single Keystroke

Instead of selecting a line, copying it, inserting a new line above or below, and pasting it, you can perform the entire set of actions with a single keystroke.

macOS Shift+Option+
Shift+Option+
Linux Shift+Alt+
Shift+Alt+
Windows Shift+Alt+
Shift+Alt+

This works with multiple lines selected, so you can quickly repeat entire chunks of text.

Here's what it looks like:

This shortcut is handy when creating an array of similarly structured items. It's also great for working with configuration files, XML files, JSON files, or any other code-adjacent file with a repetitive structure.

How To Practice It

⏱ Time: 2 minutes
🗓 Frequency: Twice daily for at least five days

Make a folder containing copies of YAML, JSON, XML, or other structured text files you work with frequently. Pick one or two and spend a couple of minutes adding new items using the shortcut.

#3 Delete Code In One Step

Instead of selecting a line, deleting it, and pressing backspace to remove the blank line, you can do all that in one step.

macOS Shift+Cmd+K
Linux Shift+Ctrl+K
Windows Shift+Ctrl+K

Here's how it works:

This works with multiple lines selected, so you can quickly remove an entire block of code if needed.

How To Practice It

⏱ Time: 1 minute
🗓 Frequency: Twice daily for at least five days

Open any file you want and go to town deleting code. It's cathartic, isn't it?

#4 Easily Rename Variables

Instead of manually finding all of the instances of a variable and changing them, or even using find and replace, use VS Code's built-in variable renaming feature.

macOS F2
Linux F2
Windows F2

This also works with function names, class names, and other identifiers.

Here's what it looks like in action:

VS Code can infer the scope for which to apply the change. If you want, you can press Shift+Enter from the rename window to preview the changes:

How To Practice It

⏱ Time: 1–2 minutes
🗓 Frequency: Twice daily for at least five days

Clone a repository from GitHub, or use one of your own, and practice renaming things with the shortcut.

#5 Quickly Peek At References

Instead of searching for references to a function in a codebase, you can take a quick peek at all references without leaving your current file.

macOS Shift+F12
Linux Shift+F12
Windows Alt+F12

You can cycle through references using the arrow keys and press Enter to move your cursor to a selected reference.

Here it is in action:

If you prefer to jump straight to the definition in a new editor tab, instead of the peek view, use F12.

How To Practice It

⏱ Time: 1–2 minutes
🗓 Frequency: Twice daily for at least five days

Clone a repository from GitHub and practice looking up references of things using the shortcut.

How To Master Keyboard Shortcuts

The practice routines I've suggested here are a good start.

To practice effectively, research suggests that you should vary the content of your practice each time. Practice on different code bases and file types. Set different objectives for yourself. Practice often and space sessions apart by several hours.

Do that, and those keystrokes will become muscle memory in no time.


The only way to become a better coder is to practice. But not all practice is equal. Learn how to use deliberate practice to take your coding skills to the next level:

The Secret To Mastering Programming
A brief guide to deliberate practice for coders.