xref: /Universal-ctags/man/tags.5.rst.in (revision 273967cd0395d319e263df3aa57ea085adca163e)
1*273967cdSHiroo HAYASHI.. _tags(5):
2*273967cdSHiroo HAYASHI
3*273967cdSHiroo HAYASHI==============================================================
4*273967cdSHiroo HAYASHItags
5*273967cdSHiroo HAYASHI==============================================================
6*273967cdSHiroo HAYASHI--------------------------------------------------------------
7*273967cdSHiroo HAYASHIVi tags file format extended in ctags projects
8*273967cdSHiroo HAYASHI--------------------------------------------------------------
9*273967cdSHiroo HAYASHI:Version: 2+
10*273967cdSHiroo HAYASHI:Manual group: Universal Ctags
11*273967cdSHiroo HAYASHI:Manual section: 5
12*273967cdSHiroo HAYASHI
13*273967cdSHiroo HAYASHIDESCRIPTION
14*273967cdSHiroo HAYASHI-----------
15*273967cdSHiroo HAYASHI
16*273967cdSHiroo HAYASHIThe contents of next section is a copy of FORMAT file in Exuberant
17*273967cdSHiroo HAYASHICtags source code in its subversion repository at sourceforge.net.
18*273967cdSHiroo HAYASHI
19*273967cdSHiroo HAYASHIExceptions introduced in Universal Ctags are explained inline with
20*273967cdSHiroo HAYASHI"EXCEPTION" marker.
21*273967cdSHiroo HAYASHI
22*273967cdSHiroo HAYASHI----
23*273967cdSHiroo HAYASHI
24*273967cdSHiroo HAYASHIProposal for extended Vi tags file format
25*273967cdSHiroo HAYASHI-----------------------------------------
26*273967cdSHiroo HAYASHI
27*273967cdSHiroo HAYASHI| Version: 0.06 DRAFT
28*273967cdSHiroo HAYASHI| Date: 1998 Feb 8
29*273967cdSHiroo HAYASHI| Author: Bram Moolenaar <Bram at vim.org> and Darren Hiebert <dhiebert at users.sourceforge.net>
30*273967cdSHiroo HAYASHI
31*273967cdSHiroo HAYASHIIntroduction
32*273967cdSHiroo HAYASHI~~~~~~~~~~~~
33*273967cdSHiroo HAYASHI
34*273967cdSHiroo HAYASHIThe file format for the "tags" file, as used by Vi and many of its
35*273967cdSHiroo HAYASHIdescendants, has limited capabilities.
36*273967cdSHiroo HAYASHI
37*273967cdSHiroo HAYASHIThis additional functionality is desired:
38*273967cdSHiroo HAYASHI
39*273967cdSHiroo HAYASHI1. Static or local tags.
40*273967cdSHiroo HAYASHI   The scope of these tags is the file where they are defined.  The same tag
41*273967cdSHiroo HAYASHI   can appear in several files, without really being a duplicate.
42*273967cdSHiroo HAYASHI2. Duplicate tags.
43*273967cdSHiroo HAYASHI   Allow the same tag to occur more then once.  They can be located in
44*273967cdSHiroo HAYASHI   a different file and/or have a different command.
45*273967cdSHiroo HAYASHI3. Support for C++.
46*273967cdSHiroo HAYASHI   A tag is not only specified by its name, but also by the context (the
47*273967cdSHiroo HAYASHI   class name).
48*273967cdSHiroo HAYASHI4. Future extension.
49*273967cdSHiroo HAYASHI   When even more additional functionality is desired, it must be possible to
50*273967cdSHiroo HAYASHI   add this later, without breaking programs that don't support it.
51*273967cdSHiroo HAYASHI
52*273967cdSHiroo HAYASHI
53*273967cdSHiroo HAYASHIFrom proposal to standard
54*273967cdSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~
55*273967cdSHiroo HAYASHI
56*273967cdSHiroo HAYASHITo make this proposal into a standard for tags files, it needs to be supported
57*273967cdSHiroo HAYASHIby most people working on versions of Vi, ctags, etc..  Currently this
58*273967cdSHiroo HAYASHIstandard is supported by:
59*273967cdSHiroo HAYASHI
60*273967cdSHiroo HAYASHIDarren Hiebert <dhiebert at users.sourceforge.net>
61*273967cdSHiroo HAYASHI	Exuberant Ctags
62*273967cdSHiroo HAYASHI
63*273967cdSHiroo HAYASHIBram Moolenaar <Bram at vim.org>
64*273967cdSHiroo HAYASHI	Vim (Vi IMproved)
65*273967cdSHiroo HAYASHI
66*273967cdSHiroo HAYASHIThese have been or will be asked to support this standard:
67*273967cdSHiroo HAYASHI
68*273967cdSHiroo HAYASHINvi
69*273967cdSHiroo HAYASHI		Keith Bostic <bostic at bsdi.com>
70*273967cdSHiroo HAYASHI
71*273967cdSHiroo HAYASHIVile
72*273967cdSHiroo HAYASHI		Tom E. Dickey <dickey at clark.net>
73*273967cdSHiroo HAYASHI
74*273967cdSHiroo HAYASHINEdit
75*273967cdSHiroo HAYASHI		Mark Edel <edel at ltx.com>
76*273967cdSHiroo HAYASHI
77*273967cdSHiroo HAYASHICRiSP
78*273967cdSHiroo HAYASHI		Paul Fox <fox at crisp.demon.co.uk>
79*273967cdSHiroo HAYASHI
80*273967cdSHiroo HAYASHILemmy
81*273967cdSHiroo HAYASHI		James Iuliano <jai at accessone.com>
82*273967cdSHiroo HAYASHI
83*273967cdSHiroo HAYASHIZeus
84*273967cdSHiroo HAYASHI		Jussi Jumppanen <jussij at ca.com.au>
85*273967cdSHiroo HAYASHI
86*273967cdSHiroo HAYASHIElvis
87*273967cdSHiroo HAYASHI		Steve Kirkendall <kirkenda at cs.pdx.edu>
88*273967cdSHiroo HAYASHI
89*273967cdSHiroo HAYASHIFTE
90*273967cdSHiroo HAYASHI		Marko Macek <Marko.Macek at snet.fri.uni-lj.si>
91*273967cdSHiroo HAYASHI
92*273967cdSHiroo HAYASHI
93*273967cdSHiroo HAYASHIBackwards compatibility
94*273967cdSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~
95*273967cdSHiroo HAYASHI
96*273967cdSHiroo HAYASHIA tags file that is generated in the new format should still be usable by Vi.
97*273967cdSHiroo HAYASHIThis makes it possible to distribute tags files that are usable by all
98*273967cdSHiroo HAYASHIversions and descendants of Vi.
99*273967cdSHiroo HAYASHI
100*273967cdSHiroo HAYASHIThis restricts the format to what Vi can handle.  The format is:
101*273967cdSHiroo HAYASHI
102*273967cdSHiroo HAYASHI1. The tags file is a list of lines, each line in the format::
103*273967cdSHiroo HAYASHI
104*273967cdSHiroo HAYASHI	{tagname}<Tab>{tagfile}<Tab>{tagaddress}
105*273967cdSHiroo HAYASHI
106*273967cdSHiroo HAYASHI
107*273967cdSHiroo HAYASHI   {tagname}
108*273967cdSHiroo HAYASHI	Any identifier, not containing white space..
109*273967cdSHiroo HAYASHI
110*273967cdSHiroo HAYASHI	EXCEPTION: Universal Ctags violates this item of the proposal;
111*273967cdSHiroo HAYASHI	tagname may contain spaces. However, tabs are not allowed.
112*273967cdSHiroo HAYASHI
113*273967cdSHiroo HAYASHI   <Tab>
114*273967cdSHiroo HAYASHI	Exactly one TAB character (although many versions of Vi can
115*273967cdSHiroo HAYASHI	handle any amount of white space).
116*273967cdSHiroo HAYASHI
117*273967cdSHiroo HAYASHI   {tagfile}
118*273967cdSHiroo HAYASHI	The name of the file where {tagname} is defined, relative to
119*273967cdSHiroo HAYASHI	the current directory (or location of the tags file?).
120*273967cdSHiroo HAYASHI
121*273967cdSHiroo HAYASHI   {tagaddress}
122*273967cdSHiroo HAYASHI	Any Ex command.  When executed, it behaves like 'magic' was
123*273967cdSHiroo HAYASHI	not set.
124*273967cdSHiroo HAYASHI
125*273967cdSHiroo HAYASHI2. The tags file is sorted on {tagname}.  This allows for a binary search in
126*273967cdSHiroo HAYASHI   the file.
127*273967cdSHiroo HAYASHI
128*273967cdSHiroo HAYASHI3. Duplicate tags are allowed, but which one is actually used is
129*273967cdSHiroo HAYASHI   unpredictable (because of the binary search).
130*273967cdSHiroo HAYASHI
131*273967cdSHiroo HAYASHIThe best way to add extra text to the line for the new functionality, without
132*273967cdSHiroo HAYASHIbreaking it for Vi, is to put a comment in the {tagaddress}.  This gives the
133*273967cdSHiroo HAYASHIfreedom to use any text, and should work in any traditional Vi implementation.
134*273967cdSHiroo HAYASHI
135*273967cdSHiroo HAYASHIFor example, when the old tags file contains::
136*273967cdSHiroo HAYASHI
137*273967cdSHiroo HAYASHI	main	main.c	/^main(argc, argv)$/
138*273967cdSHiroo HAYASHI	DEBUG	defines.c	89
139*273967cdSHiroo HAYASHI
140*273967cdSHiroo HAYASHIThe new lines can be::
141*273967cdSHiroo HAYASHI
142*273967cdSHiroo HAYASHI	main	main.c	/^main(argc, argv)$/;"any additional text
143*273967cdSHiroo HAYASHI	DEBUG	defines.c	89;"any additional text
144*273967cdSHiroo HAYASHI
145*273967cdSHiroo HAYASHINote that the ';' is required to put the cursor in the right line, and then
146*273967cdSHiroo HAYASHIthe '"' is recognized as the start of a comment.
147*273967cdSHiroo HAYASHI
148*273967cdSHiroo HAYASHIFor Posix compliant Vi versions this will NOT work, since only a line number
149*273967cdSHiroo HAYASHIor a search command is recognized.  I hope Posix can be adjusted.  Nvi suffers
150*273967cdSHiroo HAYASHIfrom this.
151*273967cdSHiroo HAYASHI
152*273967cdSHiroo HAYASHI
153*273967cdSHiroo HAYASHISecurity
154*273967cdSHiroo HAYASHI~~~~~~~~
155*273967cdSHiroo HAYASHI
156*273967cdSHiroo HAYASHIVi allows the use of any Ex command in a tags file.  This has the potential of
157*273967cdSHiroo HAYASHIa trojan horse security leak.
158*273967cdSHiroo HAYASHI
159*273967cdSHiroo HAYASHIThe proposal is to allow only Ex commands that position the cursor in a single
160*273967cdSHiroo HAYASHIfile.  Other commands, like editing another file, quitting the editor,
161*273967cdSHiroo HAYASHIchanging a file or writing a file, are not allowed.  It is therefore logical
162*273967cdSHiroo HAYASHIto call the command a tagaddress.
163*273967cdSHiroo HAYASHI
164*273967cdSHiroo HAYASHISpecifically, these two Ex commands are allowed:
165*273967cdSHiroo HAYASHI
166*273967cdSHiroo HAYASHI* A decimal line number::
167*273967cdSHiroo HAYASHI
168*273967cdSHiroo HAYASHI	89
169*273967cdSHiroo HAYASHI
170*273967cdSHiroo HAYASHI* A search command.  It is a regular expression pattern, as used by Vi,
171*273967cdSHiroo HAYASHI  enclosed in // or ??::
172*273967cdSHiroo HAYASHI
173*273967cdSHiroo HAYASHI	/^int c;$/
174*273967cdSHiroo HAYASHI	?main()?
175*273967cdSHiroo HAYASHI
176*273967cdSHiroo HAYASHIThere are two combinations possible:
177*273967cdSHiroo HAYASHI
178*273967cdSHiroo HAYASHI* Concatenation of the above, with ';' in between.  The meaning is that the
179*273967cdSHiroo HAYASHI  first line number or search command is used, the cursor is positioned in
180*273967cdSHiroo HAYASHI  that line, and then the second search command is used (a line number would
181*273967cdSHiroo HAYASHI  not be useful).  This can be done multiple times.  This is useful when the
182*273967cdSHiroo HAYASHI  information in a single line is not unique, and the search needs to start
183*273967cdSHiroo HAYASHI  in a specified line.
184*273967cdSHiroo HAYASHI  ::
185*273967cdSHiroo HAYASHI
186*273967cdSHiroo HAYASHI	/struct xyz {/;/int count;/
187*273967cdSHiroo HAYASHI	389;/struct foo/;/char *s;/
188*273967cdSHiroo HAYASHI
189*273967cdSHiroo HAYASHI* A trailing comment can be added, starting with ';"' (two characters:
190*273967cdSHiroo HAYASHI  semi-colon and double-quote).  This is used below.
191*273967cdSHiroo HAYASHI  ::
192*273967cdSHiroo HAYASHI
193*273967cdSHiroo HAYASHI	89;" foo bar
194*273967cdSHiroo HAYASHI
195*273967cdSHiroo HAYASHIThis might be extended in the future.  What is currently missing is a way to
196*273967cdSHiroo HAYASHIposition the cursor in a certain column.
197*273967cdSHiroo HAYASHI
198*273967cdSHiroo HAYASHI
199*273967cdSHiroo HAYASHIGoals
200*273967cdSHiroo HAYASHI~~~~~
201*273967cdSHiroo HAYASHI
202*273967cdSHiroo HAYASHINow the usage of the comment text has to be defined.  The following is aimed
203*273967cdSHiroo HAYASHIat:
204*273967cdSHiroo HAYASHI
205*273967cdSHiroo HAYASHI1. Keep the text short, because:
206*273967cdSHiroo HAYASHI
207*273967cdSHiroo HAYASHI   * The line length that Vi can handle is limited to 512 characters.
208*273967cdSHiroo HAYASHI   * Tags files can contain thousands of tags.  I have seen tags files of
209*273967cdSHiroo HAYASHI     several Mbytes.
210*273967cdSHiroo HAYASHI   * More text makes searching slower.
211*273967cdSHiroo HAYASHI
212*273967cdSHiroo HAYASHI2. Keep the text readable, because:
213*273967cdSHiroo HAYASHI
214*273967cdSHiroo HAYASHI   * It is often necessary to check the output of a new ctags program.
215*273967cdSHiroo HAYASHI   * Be able to edit the file by hand.
216*273967cdSHiroo HAYASHI   * Make it easier to write a program to produce or parse the file.
217*273967cdSHiroo HAYASHI
218*273967cdSHiroo HAYASHI3. Don't use special characters, because:
219*273967cdSHiroo HAYASHI
220*273967cdSHiroo HAYASHI   * It should be possible to treat a tags file like any normal text file.
221*273967cdSHiroo HAYASHI
222*273967cdSHiroo HAYASHIProposal
223*273967cdSHiroo HAYASHI~~~~~~~~
224*273967cdSHiroo HAYASHI
225*273967cdSHiroo HAYASHIUse a comment after the {tagaddress} field.  The format would be::
226*273967cdSHiroo HAYASHI
227*273967cdSHiroo HAYASHI	{tagname}<Tab>{tagfile}<Tab>{tagaddress}[;"<Tab>{tagfield}..]
228*273967cdSHiroo HAYASHI
229*273967cdSHiroo HAYASHI
230*273967cdSHiroo HAYASHI{tagname}
231*273967cdSHiroo HAYASHI	Any identifier, not containing white space..
232*273967cdSHiroo HAYASHI
233*273967cdSHiroo HAYASHI	EXCEPTION: Universal Ctags violates this item of the proposal;
234*273967cdSHiroo HAYASHI	name may contain spaces. However, tabs are not allowed.
235*273967cdSHiroo HAYASHI	Conversion, for some characters including <Tab> in the "value",
236*273967cdSHiroo HAYASHI	explained in the last of this section is applied.
237*273967cdSHiroo HAYASHI
238*273967cdSHiroo HAYASHI<Tab>
239*273967cdSHiroo HAYASHI	Exactly one TAB character (although many versions of Vi can
240*273967cdSHiroo HAYASHI	handle any amount of white space).
241*273967cdSHiroo HAYASHI
242*273967cdSHiroo HAYASHI{tagfile}
243*273967cdSHiroo HAYASHI	The name of the file where {tagname} is defined, relative to
244*273967cdSHiroo HAYASHI	the current directory (or location of the tags file?).
245*273967cdSHiroo HAYASHI
246*273967cdSHiroo HAYASHI{tagaddress}
247*273967cdSHiroo HAYASHI	Any Ex command.  When executed, it behaves like 'magic' was
248*273967cdSHiroo HAYASHI	not set.  It may be restricted to a line number or a search
249*273967cdSHiroo HAYASHI	pattern (Posix).
250*273967cdSHiroo HAYASHI
251*273967cdSHiroo HAYASHIOptionally:
252*273967cdSHiroo HAYASHI
253*273967cdSHiroo HAYASHI;"
254*273967cdSHiroo HAYASHI		semicolon + doublequote: Ends the tagaddress in way that looks
255*273967cdSHiroo HAYASHI		like the start of a comment to Vi.
256*273967cdSHiroo HAYASHI
257*273967cdSHiroo HAYASHI{tagfield}
258*273967cdSHiroo HAYASHI		See below.
259*273967cdSHiroo HAYASHI
260*273967cdSHiroo HAYASHIA tagfield has a name, a colon, and a value: "name:value".
261*273967cdSHiroo HAYASHI
262*273967cdSHiroo HAYASHI* The name consist only out of alphabetical characters.  Upper and lower case
263*273967cdSHiroo HAYASHI  are allowed.  Lower case is recommended.  Case matters ("kind:" and "Kind:
264*273967cdSHiroo HAYASHI  are different tagfields).
265*273967cdSHiroo HAYASHI
266*273967cdSHiroo HAYASHI  EXCEPTION: Universal Ctags allows users to use a numerical character
267*273967cdSHiroo HAYASHI  in the name other than its initial letter.
268*273967cdSHiroo HAYASHI
269*273967cdSHiroo HAYASHI* The value may be empty.
270*273967cdSHiroo HAYASHI  It cannot contain a <Tab>.
271*273967cdSHiroo HAYASHI
272*273967cdSHiroo HAYASHI  - When a value contains a ``\t``, this stands for a <Tab>.
273*273967cdSHiroo HAYASHI  - When a value contains a ``\r``, this stands for a <CR>.
274*273967cdSHiroo HAYASHI  - When a value contains a ``\n``, this stands for a <NL>.
275*273967cdSHiroo HAYASHI  - When a value contains a ``\\``, this stands for a single ``\`` character.
276*273967cdSHiroo HAYASHI
277*273967cdSHiroo HAYASHI  Other use of the backslash character is reserved for future expansion.
278*273967cdSHiroo HAYASHI  Warning: When a tagfield value holds an MS-DOS file name, the backslashes
279*273967cdSHiroo HAYASHI  must be doubled!
280*273967cdSHiroo HAYASHI
281*273967cdSHiroo HAYASHI  EXCEPTION: Universal Ctags introduces more conversion rules.
282*273967cdSHiroo HAYASHI
283*273967cdSHiroo HAYASHI  - When a value contains a ``\a``, this stands for a <BEL> (0x07).
284*273967cdSHiroo HAYASHI  - When a value contains a ``\b``, this stands for a <BS> (0x08).
285*273967cdSHiroo HAYASHI  - When a value contains a ``\v``, this stands for a <VT> (0x0b).
286*273967cdSHiroo HAYASHI  - When a value contains a ``\f``, this stands for a <FF> (0x0c).
287*273967cdSHiroo HAYASHI  - The characters in range 0x01 to 0x1F included, and 0x7F are
288*273967cdSHiroo HAYASHI    converted to ``\x`` prefixed hexadecimal number if the characters are
289*273967cdSHiroo HAYASHI    not handled in the above "value" rules.
290*273967cdSHiroo HAYASHI  - The leading space (0x20) and ``!`` (0x21) in {tagname} are converted
291*273967cdSHiroo HAYASHI    to ``\x`` prefixed hexadecimal number (``\x20`` and ``\x21``) if the
292*273967cdSHiroo HAYASHI    tag is not a pseudo-tag. As described later, a pseudo-tag starts with
293*273967cdSHiroo HAYASHI    ``!``. These rules are for distinguishing pseudo-tags and non pseudo-tags
294*273967cdSHiroo HAYASHI    (regular tags) when tags lines in a tag file are sorted.
295*273967cdSHiroo HAYASHI
296*273967cdSHiroo HAYASHIProposed tagfield names:
297*273967cdSHiroo HAYASHI
298*273967cdSHiroo HAYASHI=============== =============================================================================
299*273967cdSHiroo HAYASHIFIELD-NAME	DESCRIPTION
300*273967cdSHiroo HAYASHI=============== =============================================================================
301*273967cdSHiroo HAYASHIarity		Number of arguments for a function tag.
302*273967cdSHiroo HAYASHI
303*273967cdSHiroo HAYASHIclass		Name of the class for which this tag is a member or method.
304*273967cdSHiroo HAYASHI
305*273967cdSHiroo HAYASHIenum		Name of the enumeration in which this tag is an enumerator.
306*273967cdSHiroo HAYASHI
307*273967cdSHiroo HAYASHIfile		Static (local) tag, with a scope of the specified file.  When
308*273967cdSHiroo HAYASHI		the value is empty, {tagfile} is used.
309*273967cdSHiroo HAYASHI
310*273967cdSHiroo HAYASHIfunction	Function in which this tag is defined.  Useful for local
311*273967cdSHiroo HAYASHI		variables (and functions).  When functions nest (e.g., in
312*273967cdSHiroo HAYASHI		Pascal), the function names are concatenated, separated with
313*273967cdSHiroo HAYASHI		'/', so it looks like a path.
314*273967cdSHiroo HAYASHI
315*273967cdSHiroo HAYASHIkind		Kind of tag.  The value depends on the language.  For C and
316*273967cdSHiroo HAYASHI		C++ these kinds are recommended:
317*273967cdSHiroo HAYASHI
318*273967cdSHiroo HAYASHI		c
319*273967cdSHiroo HAYASHI			class name
320*273967cdSHiroo HAYASHI
321*273967cdSHiroo HAYASHI		d
322*273967cdSHiroo HAYASHI			define (from #define XXX)
323*273967cdSHiroo HAYASHI
324*273967cdSHiroo HAYASHI		e
325*273967cdSHiroo HAYASHI			enumerator
326*273967cdSHiroo HAYASHI
327*273967cdSHiroo HAYASHI		f
328*273967cdSHiroo HAYASHI			function or method name
329*273967cdSHiroo HAYASHI
330*273967cdSHiroo HAYASHI		F
331*273967cdSHiroo HAYASHI			file name
332*273967cdSHiroo HAYASHI
333*273967cdSHiroo HAYASHI		g
334*273967cdSHiroo HAYASHI			enumeration name
335*273967cdSHiroo HAYASHI
336*273967cdSHiroo HAYASHI		m
337*273967cdSHiroo HAYASHI			member (of structure or class data)
338*273967cdSHiroo HAYASHI
339*273967cdSHiroo HAYASHI		p
340*273967cdSHiroo HAYASHI			function prototype
341*273967cdSHiroo HAYASHI
342*273967cdSHiroo HAYASHI		s
343*273967cdSHiroo HAYASHI			structure name
344*273967cdSHiroo HAYASHI
345*273967cdSHiroo HAYASHI		t
346*273967cdSHiroo HAYASHI			typedef
347*273967cdSHiroo HAYASHI
348*273967cdSHiroo HAYASHI		u
349*273967cdSHiroo HAYASHI			union name
350*273967cdSHiroo HAYASHI
351*273967cdSHiroo HAYASHI		v
352*273967cdSHiroo HAYASHI			variable
353*273967cdSHiroo HAYASHI
354*273967cdSHiroo HAYASHI		When this field is omitted, the kind of tag is undefined.
355*273967cdSHiroo HAYASHI
356*273967cdSHiroo HAYASHIstruct		Name of the struct in which this tag is a member.
357*273967cdSHiroo HAYASHI
358*273967cdSHiroo HAYASHIunion		Name of the union in which this tag is a member.
359*273967cdSHiroo HAYASHI=============== =============================================================================
360*273967cdSHiroo HAYASHI
361*273967cdSHiroo HAYASHI
362*273967cdSHiroo HAYASHINote that these are mostly for C and C++.  When tags programs are written for
363*273967cdSHiroo HAYASHIother languages, this list should be extended to include the used field names.
364*273967cdSHiroo HAYASHIThis will help users to be independent of the tags program used.
365*273967cdSHiroo HAYASHI
366*273967cdSHiroo HAYASHIExamples::
367*273967cdSHiroo HAYASHI
368*273967cdSHiroo HAYASHI	asdf	sub.cc	/^asdf()$/;"	new_field:some\svalue	file:
369*273967cdSHiroo HAYASHI	foo_t	sub.h	/^typedef foo_t$/;"	kind:t
370*273967cdSHiroo HAYASHI	func3	sub.p	/^func3()$/;"	function:/func1/func2	file:
371*273967cdSHiroo HAYASHI	getflag	sub.c	/^getflag(arg)$/;"	kind:f	file:
372*273967cdSHiroo HAYASHI	inc	sub.cc	/^inc()$/;"	file: class:PipeBuf
373*273967cdSHiroo HAYASHI
374*273967cdSHiroo HAYASHI
375*273967cdSHiroo HAYASHIThe name of the "kind:" field can be omitted.  This is to reduce the size of
376*273967cdSHiroo HAYASHIthe tags file by about 15%.  A program reading the tags file can recognize the
377*273967cdSHiroo HAYASHI"kind:" field by the missing ':'.  Examples::
378*273967cdSHiroo HAYASHI
379*273967cdSHiroo HAYASHI	foo_t	sub.h	/^typedef foo_t$/;"	t
380*273967cdSHiroo HAYASHI	getflag	sub.c	/^getflag(arg)$/;"	f	file:
381*273967cdSHiroo HAYASHI
382*273967cdSHiroo HAYASHI
383*273967cdSHiroo HAYASHIAdditional remarks:
384*273967cdSHiroo HAYASHI
385*273967cdSHiroo HAYASHI* When a tagfield appears twice in a tag line, only the last one is used.
386*273967cdSHiroo HAYASHI
387*273967cdSHiroo HAYASHI
388*273967cdSHiroo HAYASHINote about line separators:
389*273967cdSHiroo HAYASHI
390*273967cdSHiroo HAYASHIVi traditionally runs on Unix systems, where the line separator is a single
391*273967cdSHiroo HAYASHIlinefeed character <NL>.  On MS-DOS and compatible systems <CR><NL> is the
392*273967cdSHiroo HAYASHIstandard line separator.  To increase portability, this line separator is also
393*273967cdSHiroo HAYASHIsupported.
394*273967cdSHiroo HAYASHI
395*273967cdSHiroo HAYASHIOn the Macintosh a single <CR> is used for line separator.  Supporting this on
396*273967cdSHiroo HAYASHIUnix systems causes problems, because most fgets() implementation don't see
397*273967cdSHiroo HAYASHIthe <CR> as a line separator.  Therefore the support for a <CR> as line
398*273967cdSHiroo HAYASHIseparator is limited to the Macintosh.
399*273967cdSHiroo HAYASHI
400*273967cdSHiroo HAYASHISummary:
401*273967cdSHiroo HAYASHI
402*273967cdSHiroo HAYASHI==============  ======================  =========================
403*273967cdSHiroo HAYASHIline separator	generated on		accepted on
404*273967cdSHiroo HAYASHI==============  ======================  =========================
405*273967cdSHiroo HAYASHI<LF>		Unix			Unix, MS-DOS, Macintosh
406*273967cdSHiroo HAYASHI<CR>		Macintosh		Macintosh
407*273967cdSHiroo HAYASHI<CR><LF>	MS-DOS			Unix, MS-DOS, Macintosh
408*273967cdSHiroo HAYASHI==============  ======================  =========================
409*273967cdSHiroo HAYASHI
410*273967cdSHiroo HAYASHIThe characters <CR> and <LF> cannot be used inside a tag line.  This is not
411*273967cdSHiroo HAYASHImentioned elsewhere (because it's obvious).
412*273967cdSHiroo HAYASHI
413*273967cdSHiroo HAYASHI
414*273967cdSHiroo HAYASHINote about white space:
415*273967cdSHiroo HAYASHI
416*273967cdSHiroo HAYASHIVi allowed any white space to separate the tagname from the tagfile, and the
417*273967cdSHiroo HAYASHIfilename from the tagaddress.  This would need to be allowed for backwards
418*273967cdSHiroo HAYASHIcompatibility.  However, all known programs that generate tags use a single
419*273967cdSHiroo HAYASHI<Tab> to separate fields.
420*273967cdSHiroo HAYASHI
421*273967cdSHiroo HAYASHIThere is a problem for using file names with embedded white space in the
422*273967cdSHiroo HAYASHItagfile field.  To work around this, the same special characters could be used
423*273967cdSHiroo HAYASHIas in the new fields, for example ``\s``.  But, unfortunately, in MS-DOS the
424*273967cdSHiroo HAYASHIbackslash character is used to separate file names.  The file name
425*273967cdSHiroo HAYASHI``c:\vim\sap`` contains ``\s``, but this is not a <Space>.  The number of
426*273967cdSHiroo HAYASHIbackslashes could be doubled, but that will add a lot of characters, and make
427*273967cdSHiroo HAYASHIparsing the tags file slower and clumsy.
428*273967cdSHiroo HAYASHI
429*273967cdSHiroo HAYASHITo avoid these problems, we will only allow a <Tab> to separate fields, and
430*273967cdSHiroo HAYASHInot support a file name or tagname that contains a <Tab> character.  This
431*273967cdSHiroo HAYASHImeans that we are not 100% Vi compatible.  However, there is no known tags
432*273967cdSHiroo HAYASHIprogram that uses something else than a <Tab> to separate the fields.  Only
433*273967cdSHiroo HAYASHIwhen a user typed the tags file himself, or made his own program to generate a
434*273967cdSHiroo HAYASHItags file, we could run into problems.  To solve this, the tags file should be
435*273967cdSHiroo HAYASHIfiltered, to replace the arbitrary white space with a single <Tab>.  This Vi
436*273967cdSHiroo HAYASHIcommand can be used::
437*273967cdSHiroo HAYASHI
438*273967cdSHiroo HAYASHI	:%s/^\([^ ^I]*\)[ ^I]*\([^ ^I]*\)[ ^I]*/\1^I\2^I/
439*273967cdSHiroo HAYASHI
440*273967cdSHiroo HAYASHI(replace ^I with a real <Tab>).
441*273967cdSHiroo HAYASHI
442*273967cdSHiroo HAYASHI
443*273967cdSHiroo HAYASHITAG FILE INFORMATION:
444*273967cdSHiroo HAYASHI
445*273967cdSHiroo HAYASHIPseudo-tag lines can be used to encode information into the tag file regarding
446*273967cdSHiroo HAYASHIdetails about its content (e.g. have the tags been sorted?, are the optional
447*273967cdSHiroo HAYASHItagfields present?), and regarding the program used to generate the tag file.
448*273967cdSHiroo HAYASHIThis information can be used both to optimize use of the tag file (e.g.
449*273967cdSHiroo HAYASHIenable/disable binary searching) and provide general information (what version
450*273967cdSHiroo HAYASHIof the generator was used).
451*273967cdSHiroo HAYASHI
452*273967cdSHiroo HAYASHIThe names of the tags used in these lines may be suitably chosen to ensure
453*273967cdSHiroo HAYASHIthat when sorted, they will always be located near the first lines of the tag
454*273967cdSHiroo HAYASHIfile.  The use of "!_TAG_" is recommended.  Note that a rare tag like "!"
455*273967cdSHiroo HAYASHIcan sort to before these lines.  The program reading the tags file should be
456*273967cdSHiroo HAYASHIsmart enough to skip over these tags.
457*273967cdSHiroo HAYASHI
458*273967cdSHiroo HAYASHIThe lines described below have been chosen to convey a select set of
459*273967cdSHiroo HAYASHIinformation.
460*273967cdSHiroo HAYASHI
461*273967cdSHiroo HAYASHITag lines providing information about the content of the tag file::
462*273967cdSHiroo HAYASHI
463*273967cdSHiroo HAYASHI    !_TAG_FILE_FORMAT	{version-number}	/optional comment/
464*273967cdSHiroo HAYASHI    !_TAG_FILE_SORTED	{0|1}			/0=unsorted, 1=sorted/
465*273967cdSHiroo HAYASHI
466*273967cdSHiroo HAYASHIThe {version-number} used in the tag file format line reserves the value of
467*273967cdSHiroo HAYASHI"1" for tag files complying with the original UNIX vi/ctags format, and
468*273967cdSHiroo HAYASHIreserves the value "2" for tag files complying with this proposal. This value
469*273967cdSHiroo HAYASHImay be used to determine if the extended features described in this proposal
470*273967cdSHiroo HAYASHIare present.
471*273967cdSHiroo HAYASHI
472*273967cdSHiroo HAYASHITag lines providing information about the program used to generate the tag
473*273967cdSHiroo HAYASHIfile, and provided solely for documentation purposes::
474*273967cdSHiroo HAYASHI
475*273967cdSHiroo HAYASHI    !_TAG_PROGRAM_AUTHOR	{author-name}	/{email-address}/
476*273967cdSHiroo HAYASHI    !_TAG_PROGRAM_NAME	{program-name}	/optional comment/
477*273967cdSHiroo HAYASHI    !_TAG_PROGRAM_URL	{URL}	/optional comment/
478*273967cdSHiroo HAYASHI    !_TAG_PROGRAM_VERSION	{version-id}	/optional comment/
479*273967cdSHiroo HAYASHI
480*273967cdSHiroo HAYASHIEXCEPTION: Universal Ctags introduces more kinds of pseudo-tags.
481*273967cdSHiroo HAYASHISee ctags-client-tools(7) about them.
482*273967cdSHiroo HAYASHI
483*273967cdSHiroo HAYASHI----
484*273967cdSHiroo HAYASHI
485*273967cdSHiroo HAYASHI
486*273967cdSHiroo HAYASHIExceptions in Universal Ctags
487*273967cdSHiroo HAYASHI--------------------------------------------
488*273967cdSHiroo HAYASHI
489*273967cdSHiroo HAYASHIUniversal Ctags supports this proposal with some
490*273967cdSHiroo HAYASHIexceptions.
491*273967cdSHiroo HAYASHI
492*273967cdSHiroo HAYASHI
493*273967cdSHiroo HAYASHIExceptions
494*273967cdSHiroo HAYASHI~~~~~~~~~~~
495*273967cdSHiroo HAYASHI
496*273967cdSHiroo HAYASHI#. {tagname} in tags file generated by Universal Ctags may contain
497*273967cdSHiroo HAYASHI   spaces and several escape sequences. Parsers for documents like Tex and
498*273967cdSHiroo HAYASHI   reStructuredText, or liberal languages such as JavaScript need these
499*273967cdSHiroo HAYASHI   exceptions. See {tagname} of Proposal section for more detail about the
500*273967cdSHiroo HAYASHI   conversion.
501*273967cdSHiroo HAYASHI
502*273967cdSHiroo HAYASHI#. "name" part of {tagfield} in a tag generated by Universal Ctags may
503*273967cdSHiroo HAYASHI   contain numeric characters, but the first character of the "name"
504*273967cdSHiroo HAYASHI   must be alphabetic.
505*273967cdSHiroo HAYASHI
506*273967cdSHiroo HAYASHI   .. NOT REVIEWED YET (above item)
507*273967cdSHiroo HAYASHI
508*273967cdSHiroo HAYASHI.. _compat-output:
509*273967cdSHiroo HAYASHI
510*273967cdSHiroo HAYASHICompatible output and weakness
511*273967cdSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
512*273967cdSHiroo HAYASHI
513*273967cdSHiroo HAYASHI.. NOT REVIEWED YET
514*273967cdSHiroo HAYASHI
515*273967cdSHiroo HAYASHIDefault behavior (``--output-format=u-ctags`` option) has the
516*273967cdSHiroo HAYASHIexceptions.  In other hand, with ``--output-format=e-ctags`` option
517*273967cdSHiroo HAYASHIctags has no exception; Universal Ctags command may use the same file
518*273967cdSHiroo HAYASHIformat as Exuberant Ctags. However, ``--output-format=e-ctags`` throws
519*273967cdSHiroo HAYASHIaway a tag entry which name includes a space or a tab
520*273967cdSHiroo HAYASHIcharacter. ``TAG_OUTPUT_MODE`` pseudo-tag tells which format is
521*273967cdSHiroo HAYASHIused when ctags generating tags file.
522*273967cdSHiroo HAYASHI
523*273967cdSHiroo HAYASHISEE ALSO
524*273967cdSHiroo HAYASHI--------
525*273967cdSHiroo HAYASHIctags(1), ctags-client-tools(7), ctags-incompatibilities(7), readtags(1)
526