views:

756

answers:

7

When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality off, or a plugin that fixes this behavior? It takes forever to load a solution with 50 files open?

Thanks in advance

+7  A: 

Have you tried deleting the .suo file?

It's a hidden file that lives beside your solution (sln) file. suo is "solution user options", and contains your last configuration, such as what tabs you left open the last time you worked on the project, so they open again when you reload the project in Visual Studio.

If you delete it, a new 'blank' suo file will be recreated silently.

Galwegian
I just tried this. It works.
jop
nice tip! thanks.
jop
It could be nice if there was a automatic function for this, but maybe it could be a great plugin, or macro.Can you automatically run a macro on shutdown?
Jesper Blad Jensen aka. Deldy
A: 

Tools-> Options -> Environment -> Startup

Select "Show empty environment"

Mitch Wheat
That stops VS from reloading the last-used project, but when you load a project it still automatically loads all the documents you had open when you closed it.
Matt Hamilton
He wants to load his solution, but not actually open any files for editing - As if you loaded the solution and then did a Window -> Close all documents, but without having to wait for all the documents to open first.
Blorgbeard
My bad. Deleting .suo is teh way to go...
Mitch Wheat
Yep, sorry not the solution I was looking for, but maybe I was not clear enough
Jesper Blad Jensen aka. Deldy
A: 

I dont think there is an option for this (or I couldnt find one) but you could probably write a macro to do this for you on project open.

This link has some code to close open files which you could adapt: http://blogs.msdn.com/djpark/

I couldnt find the answer to this particular question but a good link for ide tips and tricks is: http://blogs.msdn.com/saraford/default.aspx

alexmac
A: 

Alternative answer:

Before you close your solution, press and hold Ctrl+F4, until all windows have been closed.

Lette
Yep, but my brain is not big enough to remember that :)
Jesper Blad Jensen aka. Deldy
That's why we have sticky notes! :-)
Lette
I'd just do right click on a tab and choose close all but this - then you've only got one left to close with Ctrl+F4
Benjol
Since you're using the mouse, why not do Window -> Close All Documents? Closing all documents in one step (involves 2 clicks) must be better than two steps (involves right-click, click, keypress). Even better: my one-step solution! :-) Only one keypress (and hold, of course).
Lette
+8  A: 

You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting.

In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents:

    Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
        DTE.ExecuteCommand("Window.CloseAllDocuments")
    End Sub

Visual Studio 2008 appears to support the same events so I'm sure this would work there too.

I'm sure you could also delete the .suo file for your project in the handler if you wanted, but you'd probably want the AfterClosing event.

Steve Beedie
Thank you so much! You are my new idol :)
Jesper Blad Jensen aka. Deldy
That's an awesome trick.
Maudite
A: 

VS attempts to save the last known view. Other than the scripts mentioned above you can manually close all documents before exiting VS

Causas
A: 

ALT-W-L

That's the key combination to close all open tabs, which can be pressed before closing a project, unless you prefer clicking Window | Close All Documents before closing the project.

--Gus