ctags - create a tags file
ctags [-xvFBatwu] files ...
ctags makes a tags file for ex(1) (or vi(1)) from the specified C,
Pascal and FORTRAN sources. A tags file gives the locations of
specified objects (for C, functions, macros with argments, and
typedefs; Pascal, procedures, programs and functions; FORTRAN,
subroutines, programs and functions) in a group of files. Each line
of the tags file contains the object name, the file in which it is
defined, and an address specification for the object definition.
Output is sorted in ascending collation order (see Environment
Variables below). All objects except C typedefs are searched with a
pattern, typedefs with a line number. Specifiers are given in
separate fields on the line, separated by spaces or tabs. Using the
tags file, ex can quickly find these objects' definitions.
-x Cause ctags to print a simple function index. This is
done by assembling a list of function names, file names
on which each function is defined, the line numbers where
each function name occurs, and the text of each line.
The list is then printed on the standard output. No tags
file is created or changed.
-v Produce a page index on the standard output. This
listing contains the function name, file name, and page
number within that file (assuming 56-line pages to match
Files whose name ends in .c or .h are assumed to be C source files and
are searched for C routine and macro definitions. Others are first
examined to see if they contain any Pascal or FORTRAN routine
definitions; if not, they are processed again looking for C
Other options are:
-F Use forward searching patterns (/.../) (default).
-B Use backward searching patterns (?...?).
-a Add the information from the files to the tags file.
Unlike re-building the tags file from the original files,
this can cause the same symbol to be entered twice in the
tags file. This option should be used with caution and
then only in very special circumstances.
Hewlett-Packard Company - 1 - HP-UX Release 11i: November 2000
-t Create tags for typedefs.
-w Suppress warning diagnostics.
-u Update the specified files in tags; that is, all
references to those files are deleted, and the new values
are added to the file as in -a above. (Beware: this
option is implemented in a way which is rather slow; it
is usually faster to simply rebuild the tags file.)
The tag main is treated specially in C programs. The tag formed is
created by adding M to the beginning of name of the file, with any
trailing .c removed, and leading pathname components also removed.
This makes use of ctags practical in directories with more than one
LC_COLLATE determines the order in which the output is sorted.
LC_CTYPE determines the interpretation of the single- and/or multi-
byte characters within comments and string literals.
If LC_COLLATE or LC_CTYPE is not specified in the environment or is
set to the empty string, the value of LANG is used as a default for
each unspecified or empty variable. If LANG is not specified or is
set to the empty string, a default of ``C'' (see lang(5)) is used
instead of LANG. If any internationalization variable contains an
invalid setting, ctags behaves as if all internationalization
variables are set to ``C''. See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported with the
exception that multi-byte character file names are not supported.
Too many entries to sort.
An attempt to get additional heap space failed; the sort could
not be performed.
Unexpected end of function in file file, line line.
The tags file may be incorrect.
A } character was found unexpectedly in the first column. This
can lead to incorrect entries in the tags file.
Duplicate entry in file file, line line: name. Second entry ignored.
The same name was detected twice in the same file. A tags entry
was made only for the first name found.
Hewlett-Packard Company - 2 - HP-UX Release 11i: November 2000
Duplicate entry in files file1 and file2: name (Warning only).
The same name was detected in two different files. A tags entry
was made only for the first name found.
Create a tags file named tags in the current directory for all C
source (*.c) files and all header (*.h) files in the current
Once the tags file exists in the current directory, it can be used
with commands that support tag files (such as vi (see vi(1)).
Use the tags file with vi to edit a particular function myfunc()
located in one of the source files:
vi -t myfunc
While editing a C source file using vi, use the ex-mode tag command to
edit function myfunc():
Use vi to find main() in file myprog.c:
vi -t Mmyprog
While using vi, find main() in file myprog.c (does not have to be the
file currently being edited):
Recognition of functions, subroutines, and procedures for FORTRAN and
Pascal is done in a very simple way. No attempt is made to deal with
block structure; if there are two Pascal procedures in different
blocks with the same name, a warning message is generated.
The method of deciding whether to look for C or Pascal and FORTRAN
functions is an approximation, and can be fooled by unusual programs.
ctags does not know about #ifdefs and Pascal types.
It relies on the input being well formed to detect typedefs.
Use of -tx shows only the last line of typedefs.
ex is naive about tags files with several identical tags; it simply
chooses the first entry its (non-linear) search finds with that tag.
Such files can be created with either the -u or -a options or by
Hewlett-Packard Company - 3 - HP-UX Release 11i: November 2000
editing a tags file.
If more than one (function) definition appears on a single line, only
the first definition is indexed.
ctags was developed by the University of California, Berkeley.
tags output tags file
OTAGS temporary file used by -u
Hewlett-Packard Company - 4 - HP-UX Release 11i: November 2000