I've posted an answer in a related-but-not-duplicate thread that may help some people here. I detailed how to create macros that will deactivate a single unit's #regions by commenting out the #region and #endregion directives, with a companion for reactivating them. With the #regions deactivated the Ctrl+M+O / Collapse to Definitions function does exactly what I want it to. I hope this is useful for someone beside myself.
This option seem to be available only in C# and not in C/C++ (Visual Studio 2005). To disable outlining in C/C++ files you need to make a trick by changing the outlining color to editor's background color. To do this go to Tools > Options > Environment > Fonts and Colors > Collapsible Text > Change "Item Foreground" color to White (or whatever your background color is).
The accepted answer turns off ALL code folding. If you want to disable #region folding but collapse comments, loops, methods, etc I wrote a plugin that does this for you.
i resolved the problem for me with an environmentevent:
start macroeditor (alt+f11)
open macroproject / EnvironmentEvents
paste the follwing code:
Private Sub DocumentEvents_DocumentOpened(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentOpened
If (Not Document Is Nothing) Then
If (Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End Sub
Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
If (Not GotFocus Is Nothing) Then
If (Not GotFocus.Document Is Nothing) Then
If (GotFocus.Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End If
End Sub