ctags(C)
ctags --
create a tags file
Syntax
ctags [ -aBdFtuvwx ] [ -f
tagsfile ] files
Description
ctags makes a tags file for
vi(C)
from a list of C, Pascal, FORTRAN,
yacc(CP),
lex(CP),
and LISP source files.
A tags file gives the locations of specified objects in a group of
files. Each line of the tags file contains the object name, the file
in which it is defined, and a search pattern for the object
definition, separated by white-space. Using the tags file,
vi can quickly locate these object definitions. Depending
on the options provided to ctags, the tagged objects will
consist of subroutines, and typedef, #define,
struct, enum, and union statements.
ctags takes the following options:
-a-
Append to an existing tags file.
-B-
Use backward searching patterns (?pattern?).
-d-
Create tags for #define
cpp(CP)
macro statements that do not take arguments (this option is always
active for
XPG4 compatibility).
-f tagsfile-
Place the tag descriptions in a file specified by the argument
tagsfile. The default behavior is to place them in a file
named tags in the current working directory.
-F-
Use forward searching patterns (/pattern/) (this is the
default).
-t-
Create tags for typedefs, structs,
unions, and enums (this option is always active
for
XPG4 compatibility).
-u-
Update the specified files in the tags file, that is, all references
to them are deleted, and the new values are appended to the
file. (Note that this option is rather slow; it is usually faster to
rebuild the tags file instead.)
-v-
Print a list on the standard output containing the object name, file
name, and page number (assuming 64 line pages). Since the output
will be sorted into lexicographic order, it may be piped through
sort(C).
-w-
Suppress warning diagnostics.
-x-
Prints a list of object names, the line number and file name on
which each is defined together with the text of the line on the
standard output. This is a simple index which can be printed out as
an offline readable function index.
Files whose names end in .c or .h are assumed to
be C source files and are searched for C style routine and macro
definitions.
Files whose names end in .y are assumed to be
yacc source files.
Files whose names end in .l are assumed to be
LISP files if their first non-blank character is
``;'', ``('', or ``['', otherwise, they are
treated as lex files.
Other files are first examined to see if they contain any Pascal or
FORTRAN routine definitions, and, if not, are searched for
C style definitions.
The tag main is treated specially for C
programs. The tag formed is created by prepending M to the
name of the file, with the trailing .c and any leading
pathname components removed. This makes use of ctags
practical in directories with more than one program.
yacc and lex files each have a special tag;
yyparse is the start of the second section of the
yacc file, and yylex is the start of the second
section of the lex file.
Exit values
ctags exits with a value of 2 if the tags file
cannot be created or opened; it exits with a value of 1 if any other
type of error occurred. Successful execution results in 0 being
returned (duplicate objects are not considered errors).
Limitations
Recognition of functions, subroutines and procedures for
FORTRAN and Pascal is done in a simplistic fashion. No
attempt is made to deal with block structure; two Pascal procedures
with the same name in different blocks will result in the loss of a
reference to the first one.
ctags does not understand Pascal types.
The algorithm which looks for C, Pascal or
FORTRAN functions is not completely
foolproof. ctags relies on its input being well formed;
any syntactical errors will confuse it.
ctags finds the syntax of some cpp conditional
compilation statements confusing. For example, since ctags
does not understand #ifdef statements, any code with
unbalanced braces inside such statements will cause it to become
somewhat disoriented. Similarly, multiple lines within
#define and typedef statements will cause
ctags to enter the last line of the object, rather than
the first, as the searching pattern.
Files
/usr/bin/ctags-
ctags executable
tags -
default output tags file
See also
cc(CP),
cpp(CP),
ex(C),
lex(CP),
vi(C),
yacc(CP)
Standards conformance
ctags is conformant with:
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.
ctags was developed at the University of California at
Berkeley and is used with permission.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003