One issue I face when writing code is having to use my mouse repeatedly for the same tasks. If I want to add curly braces to some text or comment or uncomment lines of code... honestly, it can get tiring. So, I've created a helpful list of some default VS Code shortcuts to boost your speed significantly (100x).
First, let's look at some of the default shortcuts you need to know. You might have seen senior developers using them all the time in YouTube videos and demos.
**Note: Shortcuts are not listed in any specific order.
Comment line →
Windows/Linux: ctrl + /
Mac: Cmd + /
Split editor → This allows you to view two files side-by-side.
Windows/Linux: Ctrl + \
Mac: Cmd + \
Go to Line. Type a line number to jump to it →
Windows/Linux: ctrl + G
, (Type the number to jump to)
Mac: Cmd + G
, (Type the number to jump to)
Add selection to next Find match → This allows you to select multiple instances of a word or phrase and edit them simultaneously
Windows/Linux: Ctrl + D
Mac: Cmd + D
Add a cursor above/below → This adds a cursor above/below the current line
Windows/Linux: Ctrl + Alt + Up/Down
Mac: Cmd + Alt + Up/Down
Add a cursor at the clicked location →This enables multi-cursor editing
Windows/Linux: Alt + Click
Mac: Option + Click
Copy line up/down →
Windows/Linux: Shift + Alt + Up/Down
Mac: Shift + Option + Up/Down
Move line up/down →
Windows/Linux: Alt + Up/Down
Mac: Option + Up/Down
Find/ search for text →
Windows/Linux: Ctrl + F
, (Type text to search)
Mac: Cmd + F
, (Type text to search)
Open/ Close Explorer Pane →
Windows/Linux: Ctrl + B
Mac: Cmd + B
Select all occurrences of a selection →
Windows/Linux: Ctrl + Shift + L
Mac: Cmd + Shift + L
Format document → This helps keep your code clean and readable.
Windows/Linux: Shift + Alt + F
Mac: Shift + Option + F
Open the Command Palette → This gives you access to all of VS Code's commands.
Windows/Linux: Ctrl + Shift + P
Mac: Cmd + Shift + P
Close current editor →
Windows/Linux: Ctrl + W
Mac: Cmd + W
Toggle Zen Mode → This provides a distraction-free coding environment.
*This is also called the Locked-In Mode
Windows/Linux: Ctrl + K Z
Mac: Cmd + K Z
Now I can tell you that knowing all the commands alone will not make you code blazing fast, but it’s the first step. You need to use them, day in, day out till they become part of you.
There are more you can explore out, but the ones above is all you need as a Junior Dev to start coding blazing fast in VS code.
Let me know your favorite / most used shortcut in the comments.