Reputation: 2014
In vs2010 was an Outlining option to set all blocks of code appears collapsed by default. Is there some way to do same thing in vs2012?
Upvotes: 3
Views: 2140
Reputation: 88092
This isn't available as a default, however you can press CTRL + M, O when editing a code file to collapse everything.
Upvotes: 2
Reputation: 2876
Have a look at this workaround from MSDN (only works up to VS2012 though).
Could you please open the marco IDE by click Tools->Macros->Macros IDE.
You can find a modual named EnvironmentEvents in project MyMacros.
Then could you please try to add this code in EnvironmentEvents?
Private opened As Boolean
Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
If GotFocus.Document Is Nothing Then
Return
End If
If GotFocus.Document.FullName.EndsWith(".cs") And opened = True Then
DTE.ExecuteCommand("Edit.CollapsetoDefinitions")
End If
opened = False
End Sub
Private Sub DocumentEvents_DocumentOpened(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentOpened
opened = True
End Sub
Upvotes: 0
Reputation: 12546
Not as a default.
I know it's a workaround, but as Visual Studio retains the collapsed/expanded state of the outlining when closing and reopening files you could use the Outlining -> Collapse to Definitions command to quickly collapse files when you open them and the state will be retained the next time you open that file. It's pretty quick to do and much less annoying if you use the keyboard short cut for it.
If that's too painful you'll probably need to find an extension that could do what you want, though I don't of one at this point in time.
Upvotes: 2