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 7 and 2 and type the answer here:
  • Post
  • "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.

Page 1 of 3 (42 items) 123