Last updated: Apr 6, 2024
Reading time·4 min
To close all tabs in Visual Studio Code:
Ctrl
+ Shift
+ P
on Windows and LinuxCommand
+ Shift
+ P
on macOSF1
to open the Command Palette.Here is a short clip that demonstrates the process:
The same approach can be used to close all tabs without saving. When you get prompted, select Don't save.
You can also use a keyboard shortcut to close all tabs:
Ctrl+K
Ctrl+W
Cmd+K
Cmd+W
You first press Ctrl+K
, then release and then press Ctrl+W
.
You can view keyboard shortcuts for the Close All command in this table in the docs.
If you hover over the key combination in the Key
column, the keyboard
shortcuts for all operating systems are displayed.
If you need to close all tabs only in a specific editor group (when you have split screen), select the View: Close all Editors in Group instead.
The command only closes the editors (or tabs) in the selected part of the screen.
If you need to close all tabs except the current one:
Here is a short clip that demonstrates the process.
The command doesn't have a keyboard shortcut by default.
If you want to set one:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also click on the plus icon to set a keyboard shortcut.
Enter
to confirm.For example, I use Ctrl
+ F4
.
If you need to close a single tab, use the following keyboard shortcut:
Ctrl
+ W
on Windows and Linux.Cmd
+ W
on macOS.You can also use the command palette to close the active tab in VS Code.
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.If you need to change the keyboard shortcut for the command:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Enter
to confirm.You can also use other Close Tab commands by right-clicking on a tab.
As shown in the screenshot, there are multiple options:
For example, if you only want to close the tabs to the right of the current one, right-click on the given tab and select Close to the Right.
Similarly, if you only want to close the saved tabs, select the Close Saved command.
To view all available close tab commands:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can learn more about the related topics by checking out the following tutorials: