Name

ctags

Synopsis

    ctags [options]files

Create a list of function and macro names that are defined in the specified C, Pascal, FORTRAN, yacc, or lex source files. Solaris ctags can also process C++ source files. The output list (named tags by default) contains lines of the form:

              name        file        context

where name is the function or macro name, file is the source file in which name is defined, and context is a search pattern that shows the line of code containing name. After the list of tags is created, you can invoke vi on any file and type:

    :set tags=tagsfile
    :tagname

This switches the vi editor to the source file associated with the name listed in tagsfile (which you specify with -f).

GNU/Linux systems often ship with the Exuberant ctags (see http://ctags.sourceforge.net). That version also understands C++, Java, Perl, Python, flex, and bison. The Exuberant ctags accepts many more options not listed here, see ctags(1) for more information. Of particular note is the -e option, which creates tag files usable with Emacs.

Options

-a

Append tag output to existing list of tags.

-B

context uses backward search patterns.

-d

Create tags for #define macros that don’t take arguments (symbolic constants). Mac OS X only.

-f tagsfile

Place output in tagsfile (default is tags).

-F

context uses forward search patterns (default).

-t

Include C typedefs as tags.

-u

Update tags file to reflect new locations of functions (e.g., when functions are moved to a different source file). Old tags are deleted; new ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.