In VS 2010, we made a design decision to move the “X” from the right side of the Tab Well to within each tab.
Before (VS 2008)
After (VS 2010)
The majority of feedback around this change was positive, but, as with most UI changes, there has been a vocal group that preferred the older placement. When asked what they liked about the old placement, 99% of the time the response was, “I liked the ability to quickly close tabs by repeatedly clicking on the ‘X’ without moving my mouse.”
I’ll admit it: I used that feature quite a bit to quickly close tabs. That is, until I found out that there are better and more efficient ways to clean up the Tab Well. Once I discovered these, I never looked back. So, for this “Tips and Tricks” article, I wanted to share some of those ways to quickly close documents.
#1: Window->Close All Documents
Under the Window menu is a handy command: Close All Documents. Clicking this will prompt you to save your work and will then close all documents that are currently open. Yes, this does affect more than just the documents in the Tab Well – floating documents are also closed. If you don’t want to take your hands off the keyboard, simply press Alt+ W, L, to invoke the command (You can also assign it a keyboard shortcut under Tools->Options->Environment->Keyboard).
#2: Ctrl+F4
Another handy shortcut is Ctrl+F4 which, on most machines, is bound to the command Window.CloseDocumentWindow. Pressing this keyboard combination will close the current document window that has focus. Therefore, if you want to quickly get rid of a number of items in your tab well, just keep pressing Ctrl+F4 and eventually they’ll be gone.
#3: Right-Click->Close All But This
If you want to close all but one open file, simply right-click on the tab and select Close All But This. This will close all open documents (floating included) except the tab you’ve right-clicked on.
#4: Middle Click
For those that prefer to use the mouse instead of the keyboard, there’s still a quick way to close tabs: the middle click. This shortcut actually works in a number of other popular applications as well. Simply place your mouse on the tab well and middle click to close the tab. You can keep your mouse in the first spot and click away.
I’m sure there are other ways to close documents, but these are some of my favorite. Hopefully you’ll find these shortcuts useful. Please add any of your favorites that I missed to the comments.
| Weston Hutchins – Program Manager, Visual Studio Shell Team Short Bio: I started at Microsoft as an intern in 2005 and have been working in Visual Studio ever since. I’m currently a PM on the VS Shell IDE team and work on the core IDE UI and services as well as the Extension Manager and http://visualstudiogallery.com integration. Prior to my current duties, I was the SKU manager for the Visual Studio Express products. |

"Close all but this" gives me reason to get up every morning.
Works great but I wish there was a way to say "Keep at most 10 open" so unmodified ones close automatically on a LRU basis.
Don’t let the whiners bother you–moving the ‘x’ to the tab is is a great change.
I use F1 to close a tab instead of ctrl+F4. Ctrl+F4 is too awkward a key combo to hit for me. That in browsers ctrl+W has become close tab must have a reason…
Thanks for the tip. I always add the Close All Documents button to the toolbar near close button since VS 6. This helps me closing all opened docs at once.
It’s a nice change, but why at the right side?
I remember the same issue with Firefox. First the "close tab" was at the left, which ensured that you always could close documents in the tabs on the left side of the screen, without moving your mouse. But when the close button is on the right side, the button moves according to the tab size. I know this isn’t that big a deal, but it’s the little things that makes the biggest difference.
+1 for mapping ctrl+w
I’m surprised you don’t mention the middle-ground option for cleaning up tabs: Window/Windows, select all open windows you want to close, Press Close Window(s). Very useful if you don’t want to close most windows, or only very few.
+1 ctrl+w 😉
I prefer to use middle mouse and [Alt + F + C] to close current tab.
Regards,
I’ve done my own custom keys, using
Close All –> Ctrl + (NumPad).
Close Current –> Ctrl + (NumPad)1
Close all but Current –> Ctrl + (NumPad)0
Works like a charm.
+1 for Ctrl + w
Really this one.
+1 for mapping Ctrl+W!
Keeping the task "close window(s)" simple and efficient seems like an important task, dear Hutchins. I’ve had no trouble embracing VS2010 standards, though. Most likely because I do like Muneeb, adding a "close all"-button from the Customize dialog.
I like the idea you have, Ian, when a number of windows starts to disappear into "More Windows"-list on the right, it’s time to hit the "Close all"-button for me. (Yes, my desk is mostly tidy).
Mark: Switching the F1-button from the "Help is updating to reflect your recent changes, and freezes your IDE for a while"-dialog to "Close this window"… If I’d only think of it sooner, great idea. I might keep F1 as the Help-shortcut in VS2010, though.
Mapped ctrl-w as well. shift-ctrl-w closes all docs, and I want to (haven’t done it yet) map ctrl-alt-w to close all but this.
Hey Now,
Nice Post!
To close a tab we can in Visual Studio or SQL Server Management Studio we can also press
Alt + F, C
which is a hotkey combo that will open the file menu then select close that will only close the current tab. Nice way to close a tab from the keyboard.
Thx 4 the info,
Catto
Why not implement this the same way as in Google Chrome?
From: http://blog.chromium.org/2009/01/tabbed-browsing-in-google-chrome.html
"For Chrome, we came up with something a little different. Realizing that maintaining a fixed width for tabs when closing them would keep close buttons aligned under the mouse pointer, we designed a system whereby the tab strip will re-layout when you close a tab to fill the gap left, but not resize the remaining tabs, until you move your mouse away from the tab strip (thus signaling you’re done closing tabs)."
I agree with Simon. Google Chrome has the perfect balance!
+1 for Ctrl+W
This shortcut also works in many environment, like windows explorer, photoshop, IE, Opera, etc.
Why not making it the default close document shortcut for VS? Ctrl and F4 is just to far away, there is no way I can press them using only my left hand. (Small palm, big keyboard ^_^)
I’m so used to Ctrl+W being mapped to "select word" that I can’t change it now. I usually just Alt+F,C to close a document.
One can also always add more context menu items: http://blog.krisvandermast.com/VisualStudio2010AddAnExtraContextMenuItemToTheDocumentTab.aspx.
Grz, Kris.
"It’s a nice change, but why at the right side?"
Probably because the close window button is on the right side of windows, not the left, and because that’s what IE does. If this were running on OS X, then it would make sense to have it on the left.
+1 for Ctrl-w
Why don’t you just keep the old style still there as a secondary close button or keep it as an option? Anyone should be able to close the document by pressing the close button on the tab or on the right of screen, So just give users both options and let them use whichever they want. It is just a small close button, do not take much space on screen.
I find the command window good for opening and closing stuff. ctrl + alt + A to open the command window… then type closeAll (with intellisense it pops up almost immediatley).
Its also very good for opening windows especially in big projects.
I miss my good old close button, from up in the right corner 🙁 Sad nights ahead
I’d have liked to have kept at least an option for the old style… Much more space efficient 🙁
I truly hate the vs.net 2010 way of having the close buttons on the tabs. In FF I use tabbed browser extensions to get the close button at the RIGHT, like it was in vs.net for ages. I really like the close button there, not in the least because I’ve grown accustomed to have it there for many many many MANY years.
The core reason it was removed according to MS was to ‘get it in line with all the other tabbed applications out there’. Sorry but why can’t I have it optionally at the right? Just because some designer freak gets an itchy lower back side from having the close button at the right doesn’t mean all the millions of vs.net users out there suddenly have to get used to the close button an the tab. In fact, all the tabbed applications I use have the close button at the right, vs.net 2010 breaks with this and it plain and utterly SUCKS.
I added a toolbar with the extra buttons, to see if that helped, but I never click those… just because I am too used to the close button at the right.
What gain does one get from NOT having the close button there? so make it optional, please: the people who want it on the tab, let them have it, and for the people who want it at the right, enable it…
When I asked to have this feature added back to the IDE the response was that the tabs were being updated to be inline with modern tab interfaces. Although that may be true, the applications I can think of don’t use variable sized tabs, thus keeping the mouse above the x after a tab is closed. VS10’s tabs vary in size. (As for middle click, try installing Intellipoint and see what happens.)
Would it be possible to post a VSX sample on how to hook that toolbar and add a "X" back to the toolbar much like the http://www.tabsstudio.com?
The loss of the common close and the 10 steps back the toolbar/menu system took are really disappointing.
Hello, I have developed a visual studio addin to manage open documents, you may find it usefull (it’s free and open source). More information can be found here:
http://dsmaddin.codeplex.com/
Expanding on Ctrl+F4 to close the current window I went to Tools|Options and in the Environment|Keyboard section set up two new short-cuts, Ctrl+Shift+F4 for Window.CloseAllDocuments and Ctrl+Shift+Alt+F4 for File.CloseAllButThis
As someone else mentioned earlier, I’m already way too used to Ctrl+W being select word.
The real problem now is that when clicking on the tab to actually SELECT the document, you have to avoid the X button otherwise you'll close it instead.
I can bet this is why you also had to come up with "undo close document"
Been hating VS 2010… wpf was a mistake. 'friggin menus TAKE TIME to open. Unreal. Feels like a java app.
I found this page because of the key word "closing windows QUICKLY". Alas, you describe how to make this quick for the user, but I'm already quick. Visual Studio is the one who's slow!
In our solution, we have roughly 100 projects with thousandss of files total. Closing a single tab makes me wait anytime between 1 to 10 seconds. Closing several tabs makes me wait for each tab. Selecting windows in the windows dialog and hitting close has the same result, each tab goes blubb… blubb… blubb…
So, each time I close a tab I get a little mad and also grow an extra grey hair.
That's why I tried to find out what was happening and started SysInternals process monitor. I closed one tab and captured all events. To my surprise, devenv.exe touched EVERY SINGLE FILE in the whole solution! (Along with a bunch of other stuff.) WTH is going on? What are you doing? I think updating your internal list of open windows and repainting the screen should be enough. Even if you think you have to update the solution explorer (which you don't), there's no reason to go into the file system. Seriously, WTH? In fact, I'm surprised now that closing a window is so fast.
This happened in VS2005 and it happens in VS2008. Don't know about VS2010. Please investigate, please explain, please fix!
Best regards,
A high-paid professional waiter.
I have same issue ,where closing a tab takes between 1 to 10 Secs. If I continue click on close the tab, then it takes longer for first one, the next window closed fast. I am working on VS2008.
+1 for Ctrl+W, Ctrl+F4 is hard to press
The "close all but this" option is awesome. I would also like the ability to close all but a few. Is there a way to multi-select the tabs I want to keep open, and then to close everything else?
Thanks. Googled and your blog came up.
CTRL+W to close current
CTRL+ALT+W to close all but current
Thanks for saving .25 seconds .
Thanx
I prefer Ctrl+W to close current tab. I set File.Close to Ctrl+W but the shortcut is not working for me. It doesn't close the tab. Instead, selects the current word. I went back to keyboard shortcuts and the my change was still applied. There must be a bug.
For File.Close to work with Ctrl+W, you also need to remove assigned shortcut for Edit.SelectCurrentWord
One other person has mentioned that there is another problem with having the close button on each tab instead of on the tab bar; it means that when switching tabs, you might accidentally close (or pin) a tab. The occasional time I close a tab wastes all the time I saved from being able to close a tab without activating it first. If we can't configure the placement of that button, at least give us a reopen closed tab function…
Anyone know how to close the Solution Explorer, ToolBox, and Properties Panels?
There seems to be shortcuts for opening them, but not closing them.
Email is: J4M4I5M7@hotmail.com if anyone is feeling generous enough to help.
-John Mark
Nice, but I’m still missing a button to close all saved documents – and keep open the unsaved ones …