'Find Function headers' macro for Visual Studio .NET






3.67/5 (3 votes)
This macro will help you when you want to quickly move between function headers in your code.
Introduction
As you know there isn't a function like WBGoToNext
and WBGoToPrevious
in Visual Studio .NET.
So this macro will help you when you want to quickly move between function headers in your code.
It is very simple, so there is no need comment!
' FindFunction macro
'
' Writer : [Asia MVP] Smile Seo
' E-mail : seaousak@hotmail.com
'
Imports EnvDTE
Imports System.Diagnostics
Public Module FindFunction
Sub BeginningOfFunction()
Dim ts As TextSelection = DTE.ActiveWindow.Selection
ts.MoveToPoint(ts.ActivePoint.CodeElement(_
vsCMElement.vsCMElementFunction).GetStartPoint(vsCMPart.vsCMPartHeader))
End Sub
Sub EndOfFunction()
Dim ts As TextSelection = DTE.ActiveWindow.Selection
ts.MoveToPoint(ts.ActivePoint.CodeElement( _
vsCMElement.vsCMElementFunction).GetEndPoint(vsCMPart.vsCMPartHeader))
End Sub
Sub GotoFunctionHeaderUp()
On Error GoTo ErrorHandler
BeginningOfFunction()
ActiveDocument().Selection.FindText("}", vsFindOptions.vsFindOptionsBackwards)
ActiveDocument().Selection.LineUp()
BeginningOfFunction()
ErrorHandler:
End Sub
Sub GotoFunctionHeaderDown()
On Error GoTo ErrorHandler
EndOfFunction()
ActiveDocument().Selection.FindText("{")
ActiveDocument().Selection.LineDown()
BeginningOfFunction()
ErrorHandler:
End Sub
End Module