Visual Studio 2017 Undo-Close Update: The Productivity Power Tools have spun off into a bunch of more-focused extensions. To get Undo Close in Visual Studio 2017, you will want the Power Commands extension now.
Visual Studio 2013 Undo-Close Update: Since the prior options for re-opening closed tabs fell apart with the release of Visual Studio 2013, you will need the newly released Productivity Power Tools 2013.
Update: now with the ability to re-open closed tabs with Ctrl+Shift+T. This also allows you to re-open tabs closed by a project file reload, which is fantastic!
Ever tried to close a tab in Visual Studio 2010/2012 with Ctrl+W. If so, you find yourself selecting the current word in your text editor (Edit.SelectCurrentWord). I don’t use that shortcut, though I could see it being handy over my usual Ctrl+Shift+Right-/Left-Arrow. I do, however, use Ctrl+W to close windows/tabs in just about every other program I use. In order to make that shortcut work for your Visual Studio editing, you just need to assign it to File.Close instead.
For the visual, here’s a snapshot similar to what you will want (note: I already made this change before snapping a pic, so yours may look slightly different).
- Go into the Tools->Options menu.
- Select Environment->Keyboard in that window.
- Type “File.Close” in the “Show commands containing” field and select it in the list when it shows.
- Choose “Text Editor” for the “Use new shortcut in” field.
- In “Press shortcut keys” field, press Ctrl+W.
- Click “Assign” to make it happen.
- Close the Options window with the “OK” button.
Now, you can happily close windows with Ctrl+W in Visual Studio.
Next step Figure out how to get Ctrl+Shift+T to bring back the last closed window. If I find a way, I’ll post it.
Update (2012-02-16): Re-open previously closed tabs (with PowerCommands for Visual Studio 2010 [also works for Visual Studio 2012])
As Sergey Vlasov pointed out in a comment, the PowerCommands for Visual Studio 2010 adds the ability to “Undo Close” on previously closed tabs. Since it adds them as commands to Visual Studio, you can also override the default keyboard shortcut (Ctrl+Shift+Z) to a more web-browser-esque shortcut: Ctrl+Shift+T. If you already had this installed for Visual Studio 2010 when you started using Visual Studio 2012, just install the PowerCommands for Visual Studio 2010 again and it will offer to add it to Visual Studio 2012. You will still need to make the shortcut assignment in 2012.
Just like with your favorite web browser, this will cycle through previously closed tabs, resurrecting them from their graves and restoring your cursor location to right where you left off when you closed them. Amazingly enough, this also works when Visual Studio closes your active windows when a project reloads.