Does anyone know a keyboard shortcut to close all tabs except for the current one in Visual Studio? And while we're at it, the shortcut for closing all tabs? Is there a Resharper option for this? I've looked in the past and have never been able to find it.
9 Answers
I don't think there is one by default, but you can go to Tools>Options>Environment>Keyboard and bind a key to File.CloseAllButThis.
I use ctrl+alt+w

- 4,765
- 8
- 40
- 57

- 6,030
- 1
- 30
- 40
-
2if you use VSVIM you can type in the command field vsc File.CloseAllButThis, handy if you don't want to map a keystroke :D – ermagana Sep 12 '13 at 20:38
-
2There's a default way! [See my answer](http://stackoverflow.com/questions/97279/keyboard-shortcut-to-close-all-tabs-but-current-one-in-visual-studio/24896607#24896607) – Anderson Fortaleza May 06 '15 at 12:38
By default, the command File.CloseAllButThis
does not have a keyboard binding. You can set one up yourself though, as shown here:
In this example, I'm going to map CTRL + SHIFT + ALT + W to File.CloseAllButThis
in global scope. You may like to set the scope to only the text editor.
I close all documents using ALT + W + L.
This is available in Visual Studio without any special plugins or configuration. It just uses the tool bar mnemonics. The corresponding command is Window.CloseAllDocuments
in case you wish to bind it to something else.

- 300,895
- 165
- 679
- 742
-
@Drew - Thanks for pointing out the keyboards mnemonics to close all documents (not just "all but this"). Should anyone desire to customize that shortcut, it is easy to may a shortcut to Window.CloseAllDocuments. For example, I am used to Ctrl + Shift + W closing all tabs (like in web browsers and Eclipse). – nexus-bytes May 24 '13 at 21:41
Quick answer: ALT+-+A
Tested on Visual Studio 2013. On the window that you want to keep open press ALT+-, this will open the window top left menu, then press A to close all windows but the current one.

- 2,449
- 20
- 22
-
1
-
2`Alt -` has been around since at least windows 95 and really is built-in to windows and visual studio. I should have known to check that shortcut, awesome. – Maslow Aug 03 '16 at 12:45
-
2This shortcut is similar to `Alt` + `Space` in that it opens the System Menu, but for the *current MDI child window*. I wonder if this means Visual Studio actually uses MDI? – MarioDS Aug 23 '16 at 13:23
This does not 100% pertain to the original question, but I ended up here looking for this feature for VS Code.
For those like me that ended up here looking for a Visual Studio Code answer, there is an option to close all tabs in a group. I can confirm this for Mac, not 100% on Windows.
workbench.action.closeOtherEditors

- 889
- 8
- 11
If you find yourself using "Close all but this" too often, you can also try Tools \ Options \ Environment \ Documents \ [x] Reuse current document window, if saved. Combined with ReSharper's Recent Edits (ctrl-, or ctrl-e depending on keymap) you can avoid having too much open documents all the time and still quickly navigate between recently opened.

- 11,782
- 1
- 40
- 50
Sara Ford has a lot of tips like these about Visual Studio.
Here's one that references what aaronjensen said about File.CloseAllButThis
:

- 9,564
- 146
- 81
- 122

- 1,873
- 1
- 16
- 21
In order to close all documents:
Tools->Customize...->Keyboard..->Environment->Keyboard
There I've mapped command Window.CloseAllDocuments to Alt+Ctrl+F4
-
From VS2012 it is Tools->Options->Environment->Keyboard. There you can map Windows.CloseAllDocuments. – erikH Aug 18 '14 at 05:39
I follow aarojensen's method, but put it in the file menu (right click on the menu and select customize). Then Alt-F-B closes all but the current.

- 1,354
- 8
- 20
- 30

- 4,720
- 7
- 38
- 57