Visual Studio Code (VS Code) is a powerful and versatile code editor that has become a favorite among developers. One of its most attractive features is the extensive set of keyboard shortcuts that can significantly enhance your productivity. In this article, we'll explore some of the most useful VS Code shortcuts that every developer should know.
Basic Navigation
1. Open File
-
Windows/Linux:
Ctrl + P
-
Mac:
Cmd + P
Quickly open any file in your workspace by typing part of its name. This is a massive time-saver compared to manually browsing through directories.
2. Open Recent Files
-
Windows/Linux:
Ctrl + R
-
Mac:
Cmd + R
Access your recently opened files to switch between them effortlessly.
3. Go to Line/Column
-
Windows/Linux:
Ctrl + G
-
Mac:
Cmd + G
Jump to a specific line or column in your code by entering the line number and, optionally, the column number.
4. Toggle Sidebar
-
Windows/Linux:
Ctrl + B
-
Mac:
Cmd + B
Hide or show the sidebar to give yourself more screen space or access your project files.
Code Editing
5. Multi-Cursor Editing
-
Windows/Linux:
Alt + Click
-
Mac:
Option + Click
Place multiple cursors in your code to make simultaneous edits. This is especially useful for making the same change in several places.
6. Duplicate Line
-
Windows/Linux:
Shift + Alt + Down
orShift + Alt + Up
-
Mac:
Shift + Option + Down
orShift + Option + Up
Duplicate the current line or selection to quickly create copies of code.
7. Move Line Up/Down
-
Windows/Linux:
Alt + Up
orAlt + Down
-
Mac:
Option + Up
orOption + Down
Rearrange your code by moving lines up or down without having to cut and paste.
8. Comment/Uncomment Line
-
Windows/Linux:
Ctrl + /
-
Mac:
Cmd + /
Comment or uncomment the current line or selection to quickly disable or enable parts of your code.
Search and Replace
9. Find
-
Windows/Linux:
Ctrl + F
-
Mac:
Cmd + F
Search for text within the current file.
10. Find in Files
-
Windows/Linux:
Ctrl + Shift + F
-
Mac:
Cmd + Shift + F
Search for text across all files in your workspace.
11. Replace
-
Windows/Linux:
Ctrl + H
-
Mac:
Cmd + Option + F
Replace text within the current file. Use Ctrl + Shift + H
(Windows/Linux) or Cmd + Shift + H
(Mac) to replace text across all files.
Code Refactoring
12. Rename Symbol
-
Windows/Linux:
F2
-
Mac:
F2
Rename all instances of a symbol (e.g., variable, function) in your code.
13. Format Document
-
Windows/Linux:
Shift + Alt + F
-
Mac:
Shift + Option + F
Automatically format your code according to the configured style.
14. Quick Fix
-
Windows/Linux:
Ctrl + .
-
Mac:
Cmd + .
View and apply suggested code actions to fix issues or refactor code.
Debugging
15. Start/Continue Debugging
-
Windows/Linux:
F5
-
Mac:
F5
Start or continue debugging your application.
16. Step Over
-
Windows/Linux:
F10
-
Mac:
F10
Move to the next line of code without stepping into functions.
17. Step Into
-
Windows/Linux:
F11
-
Mac:
F11
Step into the functions and methods to debug them line by line.
18. Step Out
-
Windows/Linux:
Shift + F11
-
Mac:
Shift + F11
Step out of the current function or method.
19. Toggle Breakpoint
-
Windows/Linux:
F9
-
Mac:
F9
Set or remove breakpoints in your code to pause execution at specific lines.
Integrated Terminal
20. Toggle Integrated Terminal
-
Windows/Linux:
Ctrl +
` -
Mac:
Cmd +
`
Open or close the integrated terminal to run command-line tasks without leaving VS Code.
21. Create New Terminal
-
Windows/Linux:
Ctrl + Shift +
-
Mac:
Cmd + Shift +
`
Create a new terminal instance.
22. Split Terminal
-
Windows/Linux:
Ctrl + Shift + 5
-
Mac:
Cmd + Shift + 5
Split the terminal to run multiple command-line sessions side by side.
Conclusion
Mastering these VS Code shortcuts can greatly enhance your efficiency and streamline your workflow. By integrating these shortcuts into your daily coding routine, you'll find yourself working faster and more efficiently, leaving more time for creativity and problem-solving.
Feel free to explore VS Code's full list of keyboard shortcuts to find even more ways to boost your productivity. Happy coding!
Top comments (1)
Great piece! My favorites are CTRL + B to hide/display the folder explorer
and CTRL + J to hide/display the terminal. I love having as much space as possible to see code so I use these all the time to maximize space while still having quick access to VS code features, makes everything so much better.