Keyboard shortcut to close all tabs but current one in Visual Studio?

.NetVisual StudioResharper

.Net Problem Overview


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.

.Net Solutions


Solution 1 - .Net

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

Solution 2 - .Net

By default, the command File.CloseAllButThis does not have a keyboard binding. You can set one up yourself though, as shown here:

http://i.imgur.com/j3ueK.png"/>

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.

Solution 3 - .Net

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.

Solution 4 - .Net

There isn't a keyboard shortcut by default but you can bind it to a keyboard shortcut in the general environment settings (Options->Environment->Keyboard), the command is File.CloseAllButThis.

Solution 5 - .Net

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.

Solution 6 - .Net

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

enter image description here

Solution 7 - .Net

Sara Ford has a lot of tips like these about Visual Studio.

Here's one that references what aaronjensen said about File.CloseAllButThis:

https://docs.microsoft.com/en-us/archive/blogs/saraford/did-you-know-you-can-close-all-but-this-on-files-in-the-file-tab-channel-124

Solution 8 - .Net

In order to close all documents:

Tools->Customize...->Keyboard..->Environment->Keyboard

There I've mapped command Window.CloseAllDocuments to Alt+Ctrl+F4

Solution 9 - .Net

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTedView Question on Stackoverflow
Solution 1 - .NetAaron JensenView Answer on Stackoverflow
Solution 2 - .NetDrew NoakesView Answer on Stackoverflow
Solution 3 - .NetAnderson FortalezaView Answer on Stackoverflow
Solution 4 - .NetpdavisView Answer on Stackoverflow
Solution 5 - .NetIlya RyzhenkovView Answer on Stackoverflow
Solution 6 - .NetCaleb WaldnerView Answer on Stackoverflow
Solution 7 - .NetMicky McQuadeView Answer on Stackoverflow
Solution 8 - .NeterikHView Answer on Stackoverflow
Solution 9 - .NetCharley RathkopfView Answer on Stackoverflow