Click here to Skip to main content
Licence CPOL
First Posted 28 May 2002
Views 59,618
Downloads 245
Bookmarked 11 times

'Find Function headers' macro for Visual Studio .NET

By | 28 May 2002 | Article
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)

About the Author

Wooseok Seo

Software Developer (Senior)

Korea (Republic Of) Korea (Republic Of)

Member

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis works pretty well... PinmemberThomas Lunsford14:06 6 Aug '03  
Generalfails in a C++ class method PinsussBillDarcy5:12 10 Jul '03  
QuestionHow to bind PinmemberRobin7:47 4 Jun '02  
AnswerRe: How to bind PinmemberS Fewings5:15 8 Jul '03  

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.

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