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!
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
Woo Seok Seo have been a Microsoft MVP for 7 years and have translated several books into Korean. Author of C# Programming for Beginner (DevPress, 2001), he is interested in Debugging techniques and .NET technology. Get in touch with Woo Seok Seo at wooseok.seo@gmail.com