10 June 2007

ctags with PHP in vim

Another tip to code PHP effectively

#!/bin/bash
cd /path/to/framework/library
exec ctags-exuberant -f ~/.vim/mytags/framework \
-h ".php" -R \
--exclude="\.svn" \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cf \
--regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
--regex-PHP='/(public |static |abstract |protected |private )+function ([^ (]*)/\2/f/'


to load it,
:set tags=~/.vim/mytags/framework

Ctrl-], and you'll jump to the file and line of its declaration; Ctrl-T then takes you back
Ctrl-W ], it will split the current window and open the declaration in the new pane

2 comments:

Anonymous said...

Thanks. Works well.

Foobaz said...

The regex can be ignored from ctags version 5.7

ctags-5.7 (04 Sep 2007)
* Added support for interfaces and static/public/protected/private functions [PHP].