Introduction
VS Code is without a shadow of a doubt one of the most popular IDEs loved by developers. Its lightweight nature and many extensions make it one of my favorite editors. I have been using VS Code for a while and I wanted to share some of my favorite shortcuts that I regularly use for productivity.
Some people argue that you shouldn’t even use the mouse while coding. That’s the ultimate goal and if you’re interested in doing that you should probably use something like neovim. In fact, the neovim people think VS Code is for newbies. I haven’t tried neovim yet and it’s something I would like to try but I think VS Code can be a productive tool if used properly.
I will list my top 10 VS Code shortcuts I’ve come to use in my day-to-day life.
1. Navigate to the left/right tabs on the editor
When you have so many editor tabs open it becomes handy to navigate left/right without using your mouse.
macOS: ⌘ ⌥ ← / ⌘ ⌥ →
Linux: Ctrl + [PgUp/PgDn]
Windows: Ctrl + [PgUp/PgDn]
2. Show Integrated Terminal
This is a very simple but effective shortcut you can use to easily open or close the integrated IDE of the terminal. It is handy when you want to open your terminal and execute some commands quickly.
macOS: ⌃`
Linux: Ctrl + `
Windows: Ctrl + `
3. Bracket Matching
Brackets come in pairs and we often want to know where one bracket starts and where it ends. You can use this shortcut to see the opening and closing brackets. Just make sure your cursor is near either the opening or closing bracket.
macOS: ⇧⌘\
Linux: Ctrl + Shift + \
Windows: Ctrl + Shift + \
4. Navigate Back To Your Previous Position
When working on a file with hundreds of lines of code, we often jump from one position to another to understand something. Say, for example, from line 900 to 500. After looking at the code, you often want to return to your previous position. Instead of wasting time scrolling the file with your mouse, use this shortcut instead.
macOS: ⌃-
Linux: Ctrl + Alt + -
Windows: Alt+ ←
5. Navigate To The Start/End of Current Word
You can use this simple shortcut to move your cursor to either the left or right of the current word.
macOS: ⌥ + [← / →]
Linux: Ctrl + c
Windows: Ctrl + [← / →]
6. Select Multiple Occurrences Of The Same Word
Let’s say you have some variable called count and you want to select all the occurrences of the word one by one. You can use this shortcut to select all the occurrences one by one.
macOS: ⌘D
Linux: Ctrl + D
Windows: Ctrl + D
7. Move Line Up/Down
You can use this shortcut to move an entire line of code up/down without using cut and paste.
macOS: ⌥↓ / ⌥↑
Linux: Alt + [↑ / ↓]
Windows: Alt + [↑ / ↓]
8. Show Search
VS Code is very good at indexing the files inside a directory when you open an entire workspace. As a result, it can do a very good job of searching for words across many different files. I often use this shortcut when I’m looking for some word and I don’t know which file has this word. You can simply open the search explorer using this shortcut.
macOS: ⇧⌘F
Linux: Ctrl + Shift + F
Windows: Ctrl + Shift + F
9. Toggle line comment
This is also another simple but very good shortcut. We often want to quickly comment and uncomment a line of code inside a file.
macOS: ⌘/
Linux: Ctrl + /
Windows: Ctrl + /
10. Close Editor Window
Let’s say you are done working with the current open editor tab and you want to close it. Then you can use this very simple but very simple shortcut to close the open editor tab.
macOS: ⌘W
Linux: Ctrl + W
Windows: Ctrl + W
Conclusion
I hope you’ve learned something new from this article. Let me know your favorite shortcuts in the comment section. Here’s an official cheat sheet of vs code shortcuts:
Top comments (0)