Hi there
I dont know if its useful for everyone, but its something that i find so useful, especially on large classes and pages of code. It just collapses all of the functions (like regions) so you can just see the declaration.
Its esentially a macro which you can add to the VS IDE, steps below
1. Go to tools, macros, macro IDE
2. In My Macros create a module and insert the following code:
<CODE>
Public Sub CloseAllRegions()
ToggleAllRegions("C")
End Sub
Public Sub OpenAllRegions()
ToggleAllRegions("O")
End Sub
Public Sub ToggleAllRegions(ByVal Switch As String)
' in walking up through the code, if we do not see
' #endregion/end region before we get to the
' #region, then the region was closed, otherwise
' it was already open, and each time a #region is
' found, set open = false as we are only looking
' for closed regions and if we toggle an open region
' it will close...
Dim cmd As String = "Edit.ToggleOutliningExpansion"
Try
Dim open As Boolean = False
Dim ts As TextSelection = DTE.ActiveDocument.Selection
ts.EndOfDocument()
Dim ep As EditPoint = ts.ActivePoint.CreateEditPoint
Dim line As String
Do While Not ep.AtStartOfDocument
ts.StartOfLine()
ts.LineUp(True)
line = ts.Text.ToLower.Trim
If line.StartsWith("end sub") Or _
line.StartsWith("end function") Then
open = True
ElseIf line.IndexOf("sub ") Or line.IndexOf("function ") Then
If Switch = "C" Then
If open Then
DTE.ExecuteCommand(cmd)
End If
Else
If Not open Then
DTE.ExecuteCommand(cmd)
End If
End If
open = False
End If
ep = ts.ActivePoint.CreateEditPoint
Loop
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
</CODE>
Then, you can run these commands from the macro explorer and neaten up your code
I dont know if its useful for everyone, but its something that i find so useful, especially on large classes and pages of code. It just collapses all of the functions (like regions) so you can just see the declaration.
Its esentially a macro which you can add to the VS IDE, steps below
1. Go to tools, macros, macro IDE
2. In My Macros create a module and insert the following code:
<CODE>
Public Sub CloseAllRegions()
ToggleAllRegions("C")
End Sub
Public Sub OpenAllRegions()
ToggleAllRegions("O")
End Sub
Public Sub ToggleAllRegions(ByVal Switch As String)
' in walking up through the code, if we do not see
' #endregion/end region before we get to the
' #region, then the region was closed, otherwise
' it was already open, and each time a #region is
' found, set open = false as we are only looking
' for closed regions and if we toggle an open region
' it will close...
Dim cmd As String = "Edit.ToggleOutliningExpansion"
Try
Dim open As Boolean = False
Dim ts As TextSelection = DTE.ActiveDocument.Selection
ts.EndOfDocument()
Dim ep As EditPoint = ts.ActivePoint.CreateEditPoint
Dim line As String
Do While Not ep.AtStartOfDocument
ts.StartOfLine()
ts.LineUp(True)
line = ts.Text.ToLower.Trim
If line.StartsWith("end sub") Or _
line.StartsWith("end function") Then
open = True
ElseIf line.IndexOf("sub ") Or line.IndexOf("function ") Then
If Switch = "C" Then
If open Then
DTE.ExecuteCommand(cmd)
End If
Else
If Not open Then
DTE.ExecuteCommand(cmd)
End If
End If
open = False
End If
ep = ts.ActivePoint.CreateEditPoint
Loop
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
</CODE>
Then, you can run these commands from the macro explorer and neaten up your code