I've just discovered CTAGS, thanks to theTop 10 things Vi user need to know about Vim list.

Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).

To use CTAGS with PHP 5, I downloaded the CTAGS source code, and this patch. Bascially the patch adds capabilities for the private, protected and public visibilty keywords.

# wget http://kent.dl.sourceforge.net/sourceforge\ /ctags/ctags-5.5.4.tar.gz

tar -zxvf ctags-5.5.4.tar.gz

wget http://svn.bitflux.ch/repos/public/misc/ctags-php5.patch

mv ctags-php5.patch ctags-5.5.4

cd ctags-5.5.4

Now patch the php.c file

# patch php.c ctags-php5.patch

Configure build and install CTAGS

# ./configure


make install

CTAGS is now installed, we can start to use it. I'd recommend creating tag file for different projects seperately, rather than one big one in your home folder or something. So move to your folder of choice and create the tags file.

# cd /path/to/your/project

ctags -R

This may take a while depending on how many files you have. Once it is done, you're ready to start using CTAGS with Vim. The '-t' option for Vim opens the file containing that tag. So..

# vim -t 'MyClass'

... would open the MyClass.php class definition file. Once inside a file, hitting ctrl-] while the cursor is over a function/class name, Vim will attempt to open the file with that tag. Pressing ctrl-t will take you back a step.