In this article, we’ll go over some of the most useful Visual Studio Code shortcuts that will save you time and supercharge your development when using Visual Studio Code. This article covers default keyboard shortcuts for Windows, Linux and macOS.
Visual Studio Code (VS Code) is one of the most popular and most used code editors. It’s open source and free to use. It also provides support for many languages and frameworks, whether through built-in features or the extensive list of extensions available for the editor.
Please note that these Visual Studio Code shortcuts are taken from VS Code’s documentation. If some shortcuts don’t work, it could be due to changes in shortcuts in your editor or file format, or sometimes due to extensions installed.
Easy VS Code Navigation Shortcuts
This section presents all the Visual Studio Code shortcuts that allow you to navigate different parts of the editor.
Open a file
Searching for a specific file, especially as the project gets larger, can chew up a lot of time. Even if you already know where the file is, it’s definitely handy to learn this keyboard shortcut to easily open files in your project.
- Windows/Linux: ctrl + P
- macOS: command + P
Visual Studio Code comes with a lot of features and settings that you can change to fit your needs. This keyboard shortcut makes it easier to get to the settings whenever necessary.
- Windows/Linux: ctrl + ,
- macOS: command + ,
A lot of times you need more space for the open file you’re working on. So, this keyboard shortcut is handy to show or hide the sidebar whenever necessary.
- Windows/Linux: ctrl + B
- macOS: command + B
When you have a lot of tabs open and you need to move between them, one easy way to do it is with this keyboard shortcut, which shows you the list of the tabs and lets you navigate between them and choose which one you want to open.
- Windows/Linux: ctrl + shift + tab
- macOS: control + shift + tab
Keep pressing tab to switch between tabs.
Navigate tab groups
One of the nice features that Visual Studio Code provides is creating tab groups. Tab groups allow you to split up your tabs into groups, and each editor group takes a part of the screen.
This keyboard shortcut makes it easier and faster to navigate between groups in the editor group history. This shortcut also allows you to create a new group if the editor group you select in the shortcut is higher than the number of groups currently open.
- Windows/Linux: ctrl + 1 or 2 or 3
- macOS: command + 1 or 2 or 3
Open the terminal
During your development, you’ll most likely be using the terminal a lot. Visual Studio Code allows you to open a terminal window right inside the editor. This saves you from moving between the editor and the terminal and allows you to completely focus on the editor and the code.
- Windows/Linux: ctrl + J
- macOS: command + J
Open the command palette
There are lots of commands you can execute in Visual Studio Code. These commands can be related to out-of-the-box features or extension features.
With this keyboard shortcut, you can easily open the command palette. The command palette allows you to search through the commands you can use and execute them.
- Windows/Linux: ctrl + shift + P
- macOS: command + shift + P
![Visual Studio Code command palette](Visual Studio Code command palette)
During development, you’ll most probably need to make selections in your code, whether for copying, cutting, or other purposes.
Instead of doing so with your machine’s mouse, doing it with the keyboard saves you time. These keyboard shortcuts focus on making selections quickly.
Select current line
A lot of times you need to select the entire current line your cursor is at. This keyboard shortcut makes it very simple.
- Windows/Linux: ctrl + L
- macOS: command + L
How many times do you need to rename a variable, or simply change a certain repeated text or phrase throughout the entire file you’re working with?
Two keyboard shortcuts can be used in a situation similar to this. The first requires you to already have the word or phrases selected, while the other doesn’t.
With this keyboard shortcut, all you need is to have one occurrence of the text you’re looking for in the file selected. Then, by pressing the keys of the shortcut, you’ll select all its occurrences in the file.
- Windows/Linux: ctrl + shift + L
- macOS: command + shift + L
This keyboard shortcut allows you to do the same as the previous one, but without having anything selected. While the cursor is placed on a word, you can press the keys of this shortcut and the current word with all of its occurrences in the current file will be selected.
- Windows/Linux: ctrl + F2
- macOS: command + F2
Note: on macOS, make sure to press fn at the same time as F2.
Select until the end of the word
When selecting a certain part of the code, you can easily move and expand the selection with this shortcut. You can use the right arrow or the left arrow to go in the direction you want.
- Windows/Linux: shift + alt + → or ←
- macOS: shift + option + → or ←
Mastering these keyboard shortcuts will boost your development speed and makes you a coding hero. These keyboard shortcuts allow you to select across multiple lines to make necessary modifications or additions.
This saves you from repeating yourself and saves you the additional time you’d spend doing the same operation across multiple lines.
Select a column or box of code by dragging the mouse
Dragging your cursor across lines of code or text selects each line from end to end. But you can also select a group of lines only partially with this shortcut. Multiple lines will be selected, but only as much of them as you drag over.
- Windows/Linux: shift + alt + drag mouse across the lines
- macOS: shift + option + drag mouse across the lines
Select a column or box of code with arrow keys
You can do the same as above but without using your mouse. Instead of dragging a mouse, you use they keyboard arrow keys.
- Windows/Linux: ctrl + shift + alt + → or ← or ↓ or ↑
- macOS: command + shift + option + → or ← or ↓ or ↑
How to Use Find Results
All editors, even simple editors, should have a find feature so that you can find certain words, like function or variable names, phrases, or blocks of code either in the current selected file or across multiple files.
This section will go over keyboard shortcuts that will allow us to make the best out of the results of using the find feature in Visual Studio Code.
You can use this keyboard shortcut to move between find results in the active file.
- Windows/Linux/macOS: F3
Note: on macOS, make sure to press fn at the same time as F3.
Select multiple results
If you’re using the find feature to find certain bits of text so that you can modify a subset of these results, you can use this shortcut to navigate and select the find results in the active file.
- Windows/Linux: ctrl + D
- macOS: command + D
Select all results
If you’re using the find feature to do certain modifications with all the find results, this keyboard shortcut allows you to select all the find results.
- Windows/Linux: alt + enter
- macOS: option + enter
As each file or project grows, it becomes harder to find certain parts of the code. Finding errors or going to the code at a certain line can be hard when doing it manually.
These keyboard shortcuts save you the hassle and allow you to invest your time in what you actually want to do.
Go to line
Finding code at a certain line is especially helpful when you get a compile or runtime error that specifies what line of code caused it. This keyboard shortcut eliminates the need to actually find the line yourself.
- Windows/Linux: ctrl + G
- macOS: control + G
42 Visual Studio Code Shortcuts for Boosting Your Productivity
Source: Site Point