how - Visual Studio open files question




visual studio windows title changer (8)

Is it possible to open a project in Visual Studio 2008 without opening all the files that were previously opened last time I had the project open. I have a habit of keeping many files open as I am working on them, so next time I open the project, it (very slowly) loads up a bunch of files into the editor that I may not even need open. I have searched through the settings and cannot find anything to stop this behavior.


A bit of research turns up the fact that you can do it with a macro:

  • Create a new macro (or use an existing one). You should see a module called EnvironmentEvents in Macro Explorer. (For details, see here.)
  • Open the EnvironmentEvents module.
  • Put in this code:

    Public Sub CloseDocsOnExit() Handles SolutionEvents.BeforeClosing
        DTE.ExecuteCommand("Window.CloseAllDocuments")
    End Sub
    
  • Save and Build the macro.
  • Open a whole bunch of documents in your solution, then close Visual Studio.
  • Yay! No more open documents!
  • (Note: Despite that it says SolutionEvents, it also works if you're working on a project that doesn't have a solution.)

Building on top of SteveBob's answer, just do a Window -> Reset Window Layout

This should fix the tab problem. There is of course the side-effect that you'll have to redo/re-add all the windows ( output, solution explorer, properties, find, watches, immediate, etc)


I never realized how much that annoyed me as well! I haven't been able to find a setting, but in Options > Environment > Keyboard you can bind a shortcut to Window.CloseAllDocuments. ALT+X was unbound for me so I just used that. I'm interested if there's some hidden setting to automatically do this on solution exit though (or load).


I was never able to fix it, but a fresh install works correctly.


My default (without anyway of changing this as far as I know) VS will expand all the projects like that on first opening of a solution and creation of the solution user options file. as ljubomir mentioned, the best thing to do is create something to collapse all the projects.


Show hidden files in solution folder in windows explorer and you will find visual studio *.suo file (it contains user related information). Delete it, after opening solution next time it will be recreated. Seems that sometimes there are problems with this file (for example you take this file from another user's machine via source control(by the way: DO NOT PUT IT INTO SOURCE CONTROL!)); this causes not only "not opening previous tabs", but other confusing things as well, like not be able to save "startup" project between visual studio restarts.

Even typical .ignore file for source control suggests NOT to add it:

[Bb]in
*.user
*.suo
*.[Cc]ache
*.bak
*.ncb
*.log
*.pdb
*.DS_Store
[Tt]humbs.db 
_ReSharper.*
*.resharper
Ankh.NoLoad

My open documents(tabs) keep disappearing in VS2010 SP1

Backup your settings then do a devenv.exe /resetsettings.


Visual Studio 2005: All projects in solution explorer expanded on first opening of solution

Re: something like PowerPack: DPack has a solution collapse option too, and it works with 2005.

I configure it to collapse "Top Items Only" because "All Projects and Files" works too slowly and flickery for me.





projects-and-solutions