Tips and Tricks: Quickly Closing Documents

Tips and Tricks: Quickly Closing Documents

Rate This
  • Comments 42

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)

image

After (VS 2010)

image

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. 

 

image#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.

  wespic 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.
Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post
  • 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 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/

Page 2 of 3 (42 items) 123