Monday, July 24, 2006

The very exuberant Ctags!

Do you program in vim? Have you heard of exuberant ctags? No, then download it to your machine immediately, if ctags is not already in your system http://ctags.sourceforge.net/
Trust me - this simple program can save hours of frustration.

If you have a directory called source and the directory and its subdirectories contain source code - type "ctags -R" . This creates a listing of which functions are in which files. Thus if you are editing a file, and find a function which is defined in another, all what you have to do is "Ctrl - ]" to jump to its definition. "Ctrl -T" will take you back. Now, if the definition is in the same file, then you might as well just type "gD"within vim to go to it. (This is a vim capability).

Some more useful stuff with vim and Ctags:

vim -t tag Start vim and position the cursor at the file and line where "tag" is defined.
:ta tag - Find a tag.
Ctrl-] - Find the tag under the cursor.
Ctrl-T - Return to previous location before jump to tag (not widely implemented).

No comments: