Mastering Visual Studio Code (VS Code) keyboard shortcuts is essential for developers across Windows, Linux, and macOS. These shortcuts streamline coding tasks, ensuring efficient workflow and timely project completion. Explore 30 key shortcuts to enhance your coding experience and boost productivity.
VS Code Keyboard Shortcuts: The Ultimate Guide for Developers
Keyboard shortcuts in VS Code are essential for developers, streamlining and expediting tasks akin to playing an instrument. To utilize these shortcuts, installing specific extensions and plugins is necessary.
01. Search Text Across All Files
How to keep track of similar text across all your files in the project folder is one of the most prominent features of Visual Studio Code. VS Code keyboard shortcuts differ between Windows and macOS, and here they are:
- Key combination: Ctrl + Shift + F for Windows
- Key combination: Control + shift + F with macOS.
When you press the required buttons, a sidebar appears on the left side of the screen. You can enter any text there to search across all your files in the project folder. This feature proves helpful when you need to make changes to the code in every file within your project. You don’t need to import each file and adjust the text manually. This shortcut will automatically fix the problem and save a lot of time.
02. Reopen Closed Editor
Developers often deal with large projects containing hundreds of files, requiring simultaneous work on multiple files. Accidentally closing tabs while handling such a volume of files is normal. However, there’s no need to worry. Utilizing VS Code keyboard shortcuts allows you to easily access the tab or editor.
- Key combination: Ctrl + shift + T
This shortcut reopens a closed editor, so you don’t have to look for it every time you accidentally close it.
03. Add Selection to Next Find Match
This is a handy shortcut. If you find yourself needing to write the same piece of code in multiple places in Visual Studio Code, instead of writing or copy-pasting each instance individually, you can use the following command to save time.
- Key combination: CTRL+D
And choose the places where you want to write the same piece of code multiple times. If you write code anywhere, it will automatically be written in the rest of the site.
04. Delete Previous Word shortcut
There might be situations where you misspell a word while writing a long sentence, but you don’t want to repeatedly press the backspace key to delete it. In such cases, you can use the following keyboard shortcuts:
- Key combination: Ctrl + backspace for Windows
- Key combination: Control + delete with macOS.
Visual Studio Code keyboard shortcuts help you reduce the pain of repeatedly pressing the backspace button.
05. Delete Line
This is really necessary when you want to delete the previous line you just wrote. There are two ways to do it. If you just want to delete the line, use this command:
- Key combination Ctrl + X for Windows
- Control + X key combination for MacOS
In case you want to delete the line and keep it in the clipboard, use the following commands:
- Key combination Ctrl + Shift + K for Windows
- Key combination Control + Shift + K for MacOS
06. Select Words shortcut
Many developers prefer using only the keyboard and feel uncomfortable with the mouse. While you can select a word or sentence using the mouse, you can also achieve this using special keyboard commands.
- Key combination: Ctrl + Shift + Arrow keys (Arrow keys)
The keyboard shortcut sounds simple, but it’s actually quite useful in special cases.
07. Jump to the Beginning or End of a File
This is a useful VS Code keyboard shortcut. When developers work on software for months, files accumulate thousands of lines of code. Instead of holding down the page up or page down button for a while to reach the beginning or end of a file, you can quickly jump using the following commands:
- Ctrl + Home (up)
- Ctrl + End for (downwards).
These things are really important to speed up your code.
08. Move One Line with VSCode Keyboard Shortcut
Mistakes are common in coding. If you’ve written code in the wrong place and don’t want to cut and paste, you can simply select a word or a few words, press ALT, and use the up/down arrows.
- Press Alt + Up/Down arrow key
09. Add Cursor Up/Down
Situations may arise when you need to edit multiple lines of the same code. You don’t have to edit each line individually at that time—just use the following commands:
- Press Ctrl + Alt + Up / Down
- Press Ctrl + Shift + Arrow left or right.
Use a combination of Visual Studio Code keyboard shortcuts to get better results.
10. Duplicate a Line above or below
In many cases, you need to repeatedly use the same line, and the else-if statement is one of those cases. Instead of writing the same sentences every time or copying and pasting them, use the following codes:
- Press Shift + Alt + Up/Down arrow key
Duplicate as many lines as you want in both the up and down directions without any extra effort.
11. Fold or Unfold Code
Developers need to present codes to customers before releasing them into development. Therefore, the code must be easy to understand and well-documented. Folding is a good approach in such cases. You can easily fold the less important part of the code using these shortcuts:
- Press Ctrl + Shift + [ to fold.
- Press Ctrl + Shift +] to unfold
12. Navigate to a specific line
If you want to jump to a specific line in a file with thousands of lines, avoid using the up/down arrow keys, as it can be time-consuming. Instead, do the following:
- Press Ctrl + G and enter the desired page number.
13. Select the column box
Sometimes, selecting multiple texts at once using the typical process can be quite annoying, especially when accuracy is crucial. It’s challenging to precisely select many words using only the cursor. In such cases, you can use the following Visual Studio Code keyboard shortcut:
- Press Shift + Alt + Cursor
You can select text in a column box using this keyboard shortcut.
14. Join Line shortcut
This is an important VS Code shortcut for Mac and Windows used to convert several lines of code into a single line. Use the following command:
- Open “File > Preferences > Keyboard shortcuts” and then go to action.joinLines to select your choice on Windows.
- macOS press Control + J
15. Formatting Visual Studio shortcut
There are many VS Code shortcuts for Linux, but this one is particularly satisfying. Indentation is crucial in coding, and maintaining a specific format is equally important. With this shortcut, you don’t have to worry about indents during coding. Use the following keyboard shortcuts, and indents, along with other formatting, are automatically corrected.
- Press Shift + Alt + F on Windows:
- Press Shift + Option + F on MacOS
- On Ubuntu Ctrl + Shift + I on Ubuntu
Pay attention to the image given below to better understand the Visual Studio shortcut.
16. VS code shortcut Trim trailing white space
Unnecessary whitespace may appear at the end or beginning of lines of code, wasting precious memory. To address this problem, you can do the following:
- Preferences > Settings > User Settings tab
- Click the {} icon to open the document.
- Add the file “trimTrailingWhitespace”: true to the settings document and save the settings with any keybinding, such as Ctrl + K.
You can also manage VS Code keyboard shortcuts using the command palette.
17. Split editor
Developers sometimes need multiple people to edit simultaneously. However, the task is simplified with Vscode hotkeys on Windows, as it provides a specific keyboard shortcut for this purpose.
- Press Shift + Alt + \ or 2,3,4 on Windows and Ubuntu
- Press Command + \ or 2,3,4 on macOS
It is convenient for parallel editing. So you can split as many editors as you like.
18. Go to Symbol File
This is a simple shortcut, but it will help you code faster. You can access the symbol file in the following way:
- Press Ctrl + Shift + O on Windows and Ubuntu
- Press Command + Shift + O on MacOS
19. Go to the icon in the Workspace
Visual Studio Code shortcuts on Mac/Linux are similar to those on other platforms. In this case, navigate to the icon in the workspace. The keyboard shortcuts are as follows:
- Press Ctrl + T on Windows and Ubuntu
- Press Command + T on MacOS
20. Rename Symbol
Renaming a symbol is relatively easy in VS Code. You just need to select the icon you want to rename. Then, follow the steps below:
- Press F2 on Windows and Ubuntu
- Press F2 on macOS
To understand better, see the image below.
21. Opening and Closing the Sidebar
Sidebars are essential for any developer, allowing you to view your project files and other documents. However, the sidebar can take up a lot of space on the screen. You can quickly close or open it with the following commands:
- Press Ctrl + B on Windows and Ubuntu
- Press Ctrl + B on MacOS
This keyboard shortcut in Visual Studio helps a lot while using split editor as it saves a lot of space.
22. Shortcuts in Visual Studio Code Command Panel
From the command panel, you can issue any command as per your requirement. Do the following to open the command palette:
- Press Ctrl + P on Windows and Ubuntu
- Press Ctrl + P on MacOS
If you want to open a file, press Ctrl + P, and enter the file name in the command palette. The file will open in a few seconds. You can also access all commands and shortcuts from the palette. In case you forget any shortcut, just go to the command palette.
23. Open File by Matching Text
You can open files by matching text if you bind a keyboard shortcut, eliminating the need to manually navigate through folders to reopen a file that is no longer open. This approach saves a significant amount of time on a regular basis. To set it up, follow these steps:
- Enter “file -> Preferences -> Keyboard Shortcuts“
- Search for action.quick Open
- Click on it and bind a key as per your convenience.
Therefore, you can open a file without going to the folder.
24. Open Integrated Terminal
In VS Code, the built-in Terminal is quite handy. Developers often use it because of its conveniences. So there is a VS Code shortcut to open Terminal quickly. It is as follows:
Press Ctrl +, `e., backtick button
You can open it using the command palette. However, this is the best way.
25. Replace All Matching Occurrences in the Current File
A code can appear multiple times in a file. If you want to replace that code, you can easily use the VSCode shortcut on macOS. Many developers are not aware of this and replace the code manually, which requires a significant amount of time and effort. Instead, you can use the provided keyboard shortcuts:
- Press Ctrl F2 on Windows
- Press Control + F2 on MacOS
Therefore, select the desired word or group of words, press Ctrl + F2 and duplicate words will automatically appear. Then, Replace Whoever, and you’re good to go.
26. Switch Tabs
It’s pretty standard for developers to use multiple tabs at once. But you don’t need to use the mouse pointer to switch between them. Just do the following:
- Press Ctrl + 1/2/3
So press 1/2/3 according to the tab number. Specifically, if you want to move to tab 2, you just need to press the key combination Ctrl + 2.
27. Navigation history
We rarely work on all files at once in a project, typically focusing on two or three. If you don’t have enough space to split multiple editors, you can use file history. It not only saves the previous files we used but also provides a quick way to restore them. The VS Code keyboard shortcut to open history is given below:
- Press Ctrl + tab
You can also switch between history files more quickly.
- Use alt + left/right arrow
It saves time as well as provides more space for the screen.
28. Focus Debugger
Debuggers are very important for developers. You can easily control the debugger with the following keyboard shortcuts:
- Press F5 to start
- Pin Shift + F5 to stop
- Press F9 for the breakpoint
You can use the debugger quite conveniently this way. However, it would be better if you change the debugging shortcuts because the function buttons are difficult to reach.
29. Displaying Suggestions and Comment Options
IntelliSense is a great feature of Visual Studio Code, also known as code completion because it completes half-written code and provides hints. You can enable IntelliSense in the editor using the following keyboard shortcut:
- Press Ctrl + space
You can easily convert a sentence into a comment. You just need to select a group of words and do the following:
- Press Ctrl + K + C to comment
- Press Ctrl + K + U to uncomment
30. Move Definition and Reference
The Go to Definition feature opens a new tab and points to the origin of the desired symbol. To use it, place the cursor on the targeted icon, then press F12 to go to the source directly. Furthermore, if you are using a mouse, click on the icon while pressing Ctrl.
Additionally, there is a VS Code shortcut to go to reference material. Select the symbol whose reference you want to know and simply do the following:
- Press Shift + F12
Above are 30 Visual Studio Code shortcuts for Linux, Windows, and macOS to help you work faster and save a lot of time. Hope you work effectively!