Jump to Next/Previous Function Definition


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

I prefer to browse my code manually rather than using MSVC's Wizard Bar. These simple macros move the cursor up and down one function at a time in a cpp file. This is accomplished by searching for a newline character followed by an open brace ('{'). Simple as they may be, they help me get the cursor where I want it quickly and easily. I map these functions to Ctrl-Page Up and Ctrl-Page Down.

Note: They do not work with functions that have the open brace on the function definition line.

Sub GotoFunctionHeaderUp()
'DESCRIPTION: Moves cursor to the previous function definition.
	ActiveDocument.Selection.FindText "^{", dsMatchBackward + dsMatchRegExp
End Sub

Sub GotoFunctionHeaderDown()
'DESCRIPTION: Moves cursor to the previous function definition.
	ActiveDocument.Selection.LineDown dsMove, 2
	ActiveDocument.Selection.FindText "^{", dsMatchRegExp
End Sub

Josi Manuel Muilledes suggests using DevStudio commands WBGotoNext and WBGotoPrevious from WizardBar category.

Updated on: October 15, 1998.


  • Thanks

    Posted by jackaliger on 04/15/2007 04:32pm


  • ThanX~~~

    Posted by Legacy on 04/15/2002 07:00am

    Originally posted by: tomcruse

    nice~~~ ThanX~~~

  • Thank you! Nice work!

    Posted by Legacy on 12/05/2001 08:00am

    Originally posted by: B P

    Thank you for this neat and useful macro.

  • Good work, i was sooo looking for something like this to help with what i am doing

    Posted by Legacy on 10/18/2000 07:00am

    Originally posted by: Jimbo

    Can u plz tell me what command i can use to strore the current procedure name as a string....
    if i use that function to get to the start of it, how do i then "select" that line?
    (i wanna read in all the parameters of a function, so i can determine if they are inputs or outputs, and then generate a function header, to save me making a comment header my self for every function)
    thank you.

  • Great macros

    Posted by Legacy on 09/20/2000 07:00am

    Originally posted by: Peter W. Binsted

    Thank you very much! These work great, I've been trying to get these forever :)

  • I like it

    Posted by Legacy on 08/10/2000 07:00am

    Originally posted by: Jorge L. Diez

    How do I make the start of function the top line.

  • comment on comment from Jos� Manuel Mu�lledes

    Posted by Legacy on 10/15/1998 07:00am

    Originally posted by: Gert Rijs

    The WBGotoNext/Previous commands only work in a file from the
    active project (annoying if you have several projects in one workspace).
    Keith's macro's will work with any open cpp file.

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date