You can achieve the functionality you desire by creating a macro in visual studio that executes the CollapsetoDefinitions
command when ever the DocumentClosing
event is raised.
Simply go: Tools -> Macros -> Macros IDE.
Then add the following code to the EnvironmentEvents
module.
Private Sub DocumentEvents_DocumentClosing(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentClosing
Dim thread As New System.Threading.Thread(AddressOf CollapsToDefinition)
thread.Start()
End Sub
Public Sub CollapsToDefinition()
Try
If DTE.ActiveDocument Is Nothing Then Exit Sub
DTE.ExecuteCommand("Edit.CollapsetoDefinitions")
Catch
'Ignore any error
End Try
End Sub