. Updated Daily. Editions SDA India   SDA Indonesia
JAX Asia 2008 - Conference for Enterprise Java, SOA, Spring, Web Services, Ajax, Agile and more
BUSINESS ENTERPRISE SOLUTIONS ARCHITECTURE INFORMATION SECURITY WIRELESS & MOBILITY DATA & STORAGE DEVELOPMENT HARDWARE













News

Thursday, 1 February 2007

How to Use Exuberant ctags with PHP in Vim?

 

 

Matthew O’Phinney, in a new entry over his blog talks about exuberant ctags, a library that can be used to generate an index file mapping language objects to source files and the line in the source file where they are declared. He says, contrary to the name, it’s not just for the C language but it supports thirty-three different programming languages, including PHP.

He tries the exuberant ctags with Zend Framework core library. It resulted in good progress at the start. However, it was only mapping classes, and, in addition, only those defined with the single word 'class'—abstract classes and interfaces were entirely left out. So, he looked into the documentation to see if he could change the behavior.

Being a UNIX program it helped, as it was possible to add functions to the items it indexes with a simple flag. Additionally, he says one can use POSIX regular expressions to refine what it searches. He gives a sample of a script where he creates his tags index.

He explains that the script creates the tag index in the file /.vim/mytags/framework. It scans for PHP files recursively through the tree, excluding any files found in a .svn directory. The file paths in the index are created relative to the tags file. This is important because if this wasn't provided, ‘vim’ won’t be able to find the file, he informs. --PHP-kinds=+cf tells it to index classes and functions. Than he gives information about three regular expressions. The first tells it to match classes beginning with 'abstract class' as classes. The second tells it to match interfaces as classes. The last is PHP 5 methods, which begin with a visibility operator, to be matched as functions.

He says, once the index file is generated all you need to do in vim is tell it to load it— :set tags=~/.vim/mytags/framework. After this task is done, he talks about other functions that can be done here. He explains the first function to place the cursor on a class name or method name, anywhere in it, and hit Ctrl-], this will jump to the file and line of its declaration; Ctrl-T then takes you back. If you change the invocation to Ctrl-W ], it will split the current window and open the declaration in the new pane, he shows.

 

Read the Post

 
 
print save email comment

print

save

email

comment

 
 

Search SDA Asia

Free eNewsletter

SDA Asia Magazine Free Download
 
 
 
Copyright @ 2008 SDA Asia Magazine - All Right Reserved Privacy Policy | Terms of Use