Click here to Skip to main content
11,505,158 members (68,566 online)
Click here to Skip to main content

'Find Function headers' macro for Visual Studio .NET

, 28 May 2002 CPOL 63.6K 269 11
Rate this:
Please Sign up or sign in to vote.
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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Wooseok Seo
Software Developer (Senior)
Korea (Republic Of) Korea (Republic Of)
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

Comments and Discussions

 
GeneralThis works pretty well... Pin
Thomas Lunsford6-Aug-03 14:06
memberThomas Lunsford6-Aug-03 14:06 
Generalfails in a C++ class method Pin
BillDarcy10-Jul-03 5:12
sussBillDarcy10-Jul-03 5:12 
QuestionHow to bind Pin
Robin4-Jun-02 7:47
memberRobin4-Jun-02 7:47 
AnswerRe: How to bind Pin
S Fewings8-Jul-03 5:15
memberS Fewings8-Jul-03 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 29 May 2002
Article Copyright 2002 by Wooseok Seo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid