Page 1 of 1

macro for next/previous function

Posted: Sun May 20, 2007 6:30 pm
by troels_kn
I'm mainly using Textpad for writing PHP, and I have found the following macro quite useful. It simply jumps to the next function in the file (And its counterpart jumps to the previous function). It's a quick way to navigate in large files:

To implement it:

Start with a file, where there is a function defined, somewhere below your cursor. For example:

Code: Select all

<?php
// place cursor here
  function foobar() {
  }
(begin macro)
Press 'End'
From the menu select: Search > Find
[X] Regular expressions
Directions: Down
Find what: function[[:space:]]+[[:alnum:]_]+[[:space:]]?(
Press 'Find Next'
Press 'Close'
Press 'Home'
Press 'Home'
(stop macro)

For the opposite (find previous function), repeat the above, but switch the 'Directions' option in the search dialogue to 'Up', and don't press 'End' in the beginning.

I have these macros bound to Ctrl+Down and Ctrl+Up.

Enjoy.

PS.: I reckon that these macros should work with any C-like language (Including C, C++ and Java)