Recent Posts


Installing Exuberant Ctags for BBEdit


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

What are Ctags? From the horse’s mouth

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.

In other words, Ctags will allow you to select a language object (function, constant, variable, etc.) in your text editor, invoke a command, and immediately jump to the file where that object is defined.

The default Ctags program that ships with OS X works with C, Pascal, Fortran, YACC, lex, and lisp. Exuberant Ctags works with over 30 languages, including my bread and butter, PHP and Javascript.

I just started working in an OS X only environment again and had to setup my Ctags install and thought you, dear reader, might benefit

Download the Ctags Source and Extract

As previously mentioned, the version of Ctags that ships with OS X only supports a limited subset of languages. We’ll want to download and install the Exuberant Ctags package

$ curl -LO ''
$ tar -zxvf ctags-5.6.tar.gz

Configure/Make/Make Install

Next, the Holy Unix Trinity. I was able to install without any extra trickery on 10.4.x. The –prefix ensures the package will be installed to the /usr/local folder, which will prevent Apple from overwriting anything with a future software update.

$ cd ctags-5.6
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

For the paranoid, check your install

$ /usr/local/bin/ctags --version

Setup BBEdit Alias

BBEdit has a specific set of options they recommend using with Ctags, so I like to setup an alias in my .bash_profile. (the following is all one line)

alias ctags-bbedit='/usr/local/bin/ctags --excmd=number --tag-relative=no --fields=+a+m+n+S -R `pwd`'

See Chapter 14: Working With Development Tools of the BBEdit manual for more information.

Also, if you haven’t already, you may want to add /usr/local to your shell path, but I’ll leave that as an exercise for the viewer.

Tag a Source Tree

Almost there! Pick a project, navigate the to root of your source, and run the Ctags command. BBEdit makes no attempt to automate this, so you’ll want to run this whenever you make significant changes to the source (either through edits or source updates).

$ cd /path/to/source
$ ctags-bbedit
$ cat tags

I setup a cron job for each project that runs daily. Other options include some source control voodoo or adding a step to your build system.

Find a Definition!

You should now be able to open a file in your source tree, select an object (function name, constant name, etc), and invoke the Search ->Find in Definition option to jump to the file/line where the symbol is defined.

Originally published August 18, 2007

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 18th August 2007