Using ctags in TextMate

May 10th, 2006

NOTE: This article is outdated. I have since created a bundle which (in cutting-edge versions of TextMate) can be installed by unpacking the zip file and double-clicking on the CTags.tmbundle file. Help is available within the bundle.


To make navigating through code easier in TextMate I wrote this perl script a while ago. It makes use of the Exuberant ctags to create a tags file of an entire project, which can then be used to search for the definition of functions etc.

Prerequisites

The script requires the Exuberant ctags program. Easiest is to just install TmCodeBrowser, the script knows how to find the ctags program contained in it. Alternatively install ctags elsewhere and set the $CtagsPGM variable at the beginning of the script to contain the entire path.

Installation

  • Install ctags as described above
  • Download this perl script and put it somewhere
  • In TextMate create a command named Update Tags with these settings:
    • Save: Nothing
    • Command(s) ‘/path/to/tmctags’ update
    • Input: None
    • Output: Show as ToolTip
    • Activation: pick a Key Equivalent of your choice
  • In TextMate create a command named Find Tags with these settings:
    • Save: Nothing
    • Command(s) ‘/path/to/tmctags’
    • Input: None
    • Output: Show as HTML
    • Activation: pick a Key Equivalent of your choice

Usage

In any project with source code the Exuberant ctags program can handle, use the Update Tags command created above. This will create a file named tmtags at the projects root. If you are not in a project, the script will search for a tmtags in the directory where the current file is and in all parent directories. If so it will use that location, otherwise it will create the tmtags file in the current files directory. A ToolTip will let you know where the file was created/updated.

Once the tmtags file is created, use the Find Tags command created above to find the definition(s) of any function currently under the caret. The script will create output similar to this:

Picture 1.jpg

Click on the blue link to jump to that file and line.

Entry Filed under: OS X, TextMate


Calendar

May 2017
M T W T F S S
« Jun    
1234567
891011121314
15161718192021
22232425262728
293031  

Most Recent Posts