8.5.2. The New tags Format
Traditionally, a tags file has three tab-separated
fields: the tag name (typically an identifier), the source file
containing the tag, and an indication of where to find the identifier.
This indication is either a simple line number, or
a nomagic search
pattern enclosed either in slashes or question marks.
Furthermore, the tags file is always sorted.
This is the format generated by the UNIX ctags program.
In fact, many versions of vi allowed any
command in the search pattern field (a rather gaping security hole).
Furthermore, due to an undocumented implementation quirk,
if the line ended with a semicolon and then a double-quote
(;"), anything following those two
characters would be ignored.
(The double-quote starts a comment, as it does in .exrc
files.)
The new format is backwards-compatible with the traditional one.
The first three fields are the same: tag, filename, and search pattern.
Exuberant ctags only generates search patterns, not
arbitrary commands. Extended attributes are placed after a
separating ;".
Each attribute is separated from the next by a tab character,
and consists of two colon-separated subfields.
The first subfield is a keyword describing the attribute, the
second is the actual value.
Table 8.2
lists the supported keywords.
Table 8.2. Extended ctags Keywords
If the field does not contain a colon, it is assumed to be of
type kind.
Here are some examples:
ARRAYMAXED awk.h 427;" d
AVG_CHAIN_MAX array.c 38;" d file:
array.c array.c 1;" F
ARRAYMAXED is a C #define macro
defined in awk.h. AVG_CHAIN_MAX
is also a C macro but it is used only in array.c.
The third line is a bit different: it is a tag for the actual source file!
This is generated with the -i F option to Exuberant
ctags, and allows you to give the command
:tag array.c. More usefully, you can put the
cursor over a filename and use the ^]
command to go to that file.
Within the value part of each attribute, the characters
backslash, tab, carriage return and newline should be
encoded as \\, \t,
\r, and \n, respectively.
Extended tags files may have some number of initial
tags that begin with !_TAG_.
These tags usually sort to the
front of the file, and are useful for identifying which program
created the file.
Here is what Exuberant ctags generates:
!_TAG_FILE_FORMAT 2 /extended format; ..../
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /darren@hiebert.com/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://home.hiwaay.net/~darren/ctags /.../
!_TAG_PROGRAM_VERSION 2.0.3 /with C++ support/
Editors may take advantage of these special tags to implement
special features. For example, vim pays attention
to the !_TAG_FILE_SORTED tag and will use a
binary search to search the tags file
instead of a linear search if the file is indeed sorted.
If you use tags files,
we recommend that you get and install Exuberant ctags.