Unix Articles |
|||||||
|---|---|---|---|---|---|---|---|
|
HOME Object Libraries Tree Climbing Title Bar |
|||||||
|
Speedier C Programming with ctagsIf you vi or vim and do much C programming, then ctags is a very handy tool. ctags can make it possible to switch among all of your source code files without ever leaving the current editing session. If you're looking at a function call and want to edit the source file containing the function itself, all you need to do is cursor to the function call, type CONTROL-], and vi will load the correct source file, and position the cursor at the start of the function. When you're finished (remember to save the edits first), the command :e# returns you to the initial source file. ctags doesn't need a lot of command line arguments, other than a list of the
C source files we'd like to have tags for. If the files are
located in other directories, their paths will need to be provided as well; however,
relational paths such as It is convenient to put a line for ctags in our Makefiles, following the compile directive, so that our tags will stay current as we modify our source files. When run, ctags creates a file in the current directory called tags, which is a human-readable listing of all of the tag references for the source files that were specified. vi will automatically reference this file whenever the CONTROL-] key is used on a function call. Note that the function call selected must be in one of the source files listed on the ctags command line. ctags also has some other talents, such as being able to generate an index of the function calls in your source file (parameter: -x), a detailed list of each function call, its source file, and the page of the source file on which it exists (-v), and it will even generate tags for typedef statements (-t). Referring to the ctags provided with HPUX 9, there are a few limitations to the utility. Specifically ctags will not work well with C++. It parses the file as a C program, and generates many duplicate reference complaints. Given this problem the tags will still work for those functions which are not overloaded in the ctags file list. Short of changing to a different editor, ctags is an excellent utility that enhances vi editing for C programs. Thumbs up! |
||||||
|
HOME Object Libraries Tree Climbing Title Bar |
|||||||