Format
ctags [–aBFwx]
[–f tagfile] sourcefile
…
Description
ctags creates
a file named tags in the current directory. It summarizes the
locations of various objects in the C source files named on the command
line. All files with a .c or .h suffix are treated as
C source files.
For C source code, ctags summarizes
function, macro and typedef definitions. See tags — Format of the tags file for a description of the format of the tags file.
The tags file
is used by ex, more,
and vi to support the tag command.
The tag command can be used to edit the
file containing a name in the tags file.
For
ex and
vi,
the command is:
: tag name
For
more,
the command is:
:tname
After
these commands are run, the tags file is searched for name.
If it is found, the file associated in the tags file with that
name is loaded and the line containing the name is
made the current line.
Localization
ctags uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_COLLECT
- LC_CTYPE
- LC_MESSAGES
- LC_TIME
See Localization for more
information.
Files
ctags uses
the following file:
- tags
- Output tags file
Usage notes
- It can be difficult to recognize a function definition in C source
code. Because ctags does not know which
C preprocessor symbols are defined, there may be some misplaced function
definition information if sections of code within #if...#endif are
not complete blocks.
- ctags invokes the sort internally.
- ctags makes special provision for the main() function,
which may occur in several C source files. The tags file contains
an entry for the first main() routine found.
For all occurrences of main(), including
the first, the tags file contains an entry for Mname,
where name is the name of the input source file, with the .c suffix
and any leading pathname components removed. For example, a tags file
created for a C source code file named foo.c would contain
an entry for Mfoo, which represents the main() routine
in foo.c).
- ctags uses sort to
sort the file by tag name, according to the POSIX locale's collation
sequence.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Unknown command-line option
- Cannot create the output file
- Cannot open the output file
- One of the input files was unrecognized
Portability
POSIX.2, X/Open Portability Guide, 4.2BSD and
higher.
This
utility only understands characters from the POSIX locale.
The –B, –F,
and –w options are extensions to the POSIX
and XPG standards.