1etags(1) GNU Tools etags(1)
2
3
4
6 etags, ctags - generate tag file for Emacs, vi
7
9 etags [-aCDGIRVh] [-i file] [-l language]
10 [-o tagfile] [-r regexp] [--parse-stdin=file]
11 [--append] [--no-defines] [--no-globals] [--include=file]
12 [--ignore-indentation] [--language=language] [--no-members]
13 [--output=tagfile] [--regex=regexp] [--no-regex] [--help] [--version]
14 file ...
15
16 ctags [-aCdgIRVh] [-BtTuvwx] [-l language]
17 [-o tagfile] [-r regexp] [--parse-stdin=file]
18 [--append] [--backward-search] [--cxref] [--defines] [--forward-search]
19 [--globals] [--ignore-indentation] [--language=language] [--members]
20 [--output=tagfile] [--regex=regexp] [--typedefs] [--typedefs-and-c++]
21 [--update] [--help] [--version] file ...
22
24 The etags program is used to create a tag table file, in a format un‐
25 derstood by emacs(1); the ctags program is used to create a similar ta‐
26 ble in a format understood by vi(1). Both forms of the program under‐
27 stand the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Er‐
28 lang, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, makefile, Pascal, Perl,
29 PHP, Postscript, Python, Prolog, Scheme and most assembler-like syntax‐
30 es. Both forms read the files specified on the command line, and write
31 a tag table (defaults: TAGS for etags, tags for ctags) in the current
32 working directory. Files specified with relative file names will be
33 recorded in the tag table with file names relative to the directory
34 where the tag table resides. If the tag table is in /dev, however, the
35 file names are made relative to the working directory. Files specified
36 with absolute file names will be recorded with absolute file names.
37 Files generated from a source file--like a C file generated from a
38 source Cweb file--will be recorded with the name of the source file.
39 The programs recognize the language used in an input file based on its
40 file name and contents. The --language switch can be used to force
41 parsing of the file names following the switch according to the given
42 language, overriding guesses based on filename extensions.
43
45 Some options make sense only for the vi style tag files produced by
46 ctags; etags does not recognize them. The programs accept unambiguous
47 abbreviations for long option names.
48
49 -a, --append
50 Append to existing tag file. (For vi-format tag files, see also
51 --update.)
52
53 -B, --backward-search
54 Tag files written in the format expected by vi contain regular
55 expression search instructions; the -B option writes them using
56 the delimiter `?', to search backwards through files. The de‐
57 fault is to use the delimiter `/', to search forwards through
58 files. Only ctags accepts this option.
59
60 --declarations
61 In C and derived languages, create tags for function declara‐
62 tions, and create tags for extern variables unless --no-globals
63 is used.
64
65 -d, --defines
66 Create tag entries for C preprocessor constant definitions and
67 enum constants, too. Since this is the default behavior of
68 etags, only ctags accepts this option.
69
70 -D, --no-defines
71 Do not create tag entries for C preprocessor constant defini‐
72 tions and enum constants. This may make the tags file much
73 smaller if many header files are tagged. Since this is the de‐
74 fault behavior of ctags, only etags accepts this option.
75
76 --globals
77 Create tag entries for global variables in C, C++, Objective C,
78 Java, and Perl. Since this is the default behavior of etags,
79 only ctags accepts this option.
80
81 --no-globals
82 Do not tag global variables. Typically this reduces the file
83 size by one fourth. Since this is the default behavior of
84 ctags, only etags accepts this option.
85
86 -i file, --include=file
87 Include a note in the tag file indicating that, when searching
88 for a tag, one should also consult the tags file file after
89 checking the current file. Only etags accepts this option.
90
91 -I, --ignore-indentation
92 Don't rely on indentation as much as we normally do. Currently,
93 this means not to assume that a closing brace in the first col‐
94 umn is the final brace of a function or structure definition in
95 C and C++.
96
97 -l language, --language=language
98 Parse the following files according to the given language. More
99 than one such options may be intermixed with filenames. Use
100 --help to get a list of the available languages and their de‐
101 fault filename extensions. The `auto' language can be used to
102 restore automatic detection of language based on the file name.
103 The `none' language may be used to disable language parsing al‐
104 together; only regexp matching is done in this case (see the
105 --regex option).
106
107 --members
108 Create tag entries for variables that are members of structure-
109 like constructs in C++, Objective C, Java. This is the default
110 for etags.
111
112 --no-members
113 Do not tag member variables. This is the default for ctags.
114
115 --packages-only
116 Only tag packages in Ada files.
117
118 --parse-stdin=file
119 May be used (only once) in place of a file name on the command
120 line. etags will read from standard input and mark the produced
121 tags as belonging to the file FILE.
122
123 -o tagfile, --output=tagfile
124 Explicit name of file for tag table; overrides default TAGS or
125 tags. (But ignored with -v or -x.)
126
127 -r regexp, --regex=regexp
128
129 Make tags based on regexp matching for the files following this
130 option, in addition to the tags made with the standard parsing
131 based on language. May be freely intermixed with filenames and
132 the -R option. The regexps are cumulative, i.e. each such op‐
133 tion will add to the previous ones. The regexps are of one of
134 the forms:
135 [{language}]/tagregexp/[nameregexp/]modifiers
136 @regexfile
137
138 where tagregexp is used to match the tag. It should not match
139 useless characters. If the match is such that more characters
140 than needed are unavoidably matched by tagregexp, it may be use‐
141 ful to add a nameregexp, to narrow down the tag scope. ctags
142 ignores regexps without a nameregexp. The syntax of regexps is
143 the same as in emacs. The following character escape sequences
144 are supported: \a, \b, \d, \e, \f, \n, \r, \t, \v, which respec‐
145 tively stand for the ASCII characters BEL, BS, DEL, ESC, FF, NL,
146 CR, TAB, VT.
147 The modifiers are a sequence of 0 or more characters among i,
148 which means to ignore case when matching; m, which means that
149 the tagregexp will be matched against the whole file contents at
150 once, rather than line by line, and the matching sequence can
151 match multiple lines; and s, which implies m and means that the
152 dot character in tagregexp matches the newline char as well.
153 The separator, which is / in the examples, can be any character
154 different from space, tab, braces and @. If the separator char‐
155 acter is needed inside the regular expression, it must be quoted
156 by preceding it with \.
157 The optional {language} prefix means that the tag should be cre‐
158 ated only for files of language language, and ignored otherwise.
159 This is particularly useful when storing many predefined regexps
160 in a file.
161 In its second form, regexfile is the name of a file that con‐
162 tains a number of arguments to the --regex= option, one per
163 line. Lines beginning with a space or tab are assumed to be
164 comments, and ignored.
165
166 Here are some examples. All the regexps are quoted to protect
167 them from shell interpretation.
168
169 Tag the DEFVAR macros in the emacs source files:
170 --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
171
172 Tag VHDL files (this example is a single long line, broken here
173 for formatting reasons):
174 --language=none --regex='/[ \t]*\(ARCHITECTURE\|\ CONFIGURA‐
175 TION\) +[^ ]* +OF/' --regex='/[ \t]*\ \(ATTRIBUTE\|ENTITY\|FUNC‐
176 TION\|PACKAGE\( BODY\)?\ \|PROCE‐
177 DURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
178
179 Tag TCL files (this last example shows the usage of a tagreg‐
180 exp):
181 --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
182
183 A regexp can be preceded by {lang}, thus restricting it to match
184 lines of files of the specified language. Use etags --help to
185 obtain a list of the recognised languages. This feature is par‐
186 ticularly useful inside regex files. A regex file contains one
187 regex per line. Empty lines, and those lines beginning with
188 space or tab are ignored. Lines beginning with @ are references
189 to regex files whose name follows the @ sign. Other lines are
190 considered regular expressions like those following --regex.
191 For example, the command
192 etags --regex=@regex.file *.c
193 reads the regexes contained in the file regex.file.
194
195 -R, --no-regex
196 Don't do any more regexp matching on the following files. May
197 be freely intermixed with filenames and the --regex option.
198
199 -t, --typedefs
200 Record typedefs in C code as tags. Since this is the default
201 behavior of etags, only ctags accepts this option.
202
203 -T, --typedefs-and-c++
204 Generate tag entries for typedefs, struct, enum, and union tags,
205 and C++ member functions. Since this is the default behavior of
206 etags, only ctags accepts this option.
207
208 -u, --update
209 Update tag entries for files specified on command line, leaving
210 tag entries for other files in place. Currently, this is imple‐
211 mented by deleting the existing entries for the given files and
212 then rewriting the new entries at the end of the tags file. It
213 is often faster to simply rebuild the entire tag file than to
214 use this. Only ctags accepts this option.
215
216 -v, --vgrind
217 Instead of generating a tag file, write index (in vgrind format)
218 to standard output. Only ctags accepts this option.
219
220 -x, --cxref
221 Instead of generating a tag file, write a cross reference (in
222 cxref format) to standard output. Only ctags accepts this op‐
223 tion.
224
225 -h, -H, --help
226 Print usage information. Followed by one or more --lan‐
227 guage=LANG prints detailed information about how tags are creat‐
228 ed for LANG.
229
230 -V, --version
231 Print the current version of the program (same as the version of
232 the emacs etags is shipped with).
233
234
236 `emacs' entry in info; GNU Emacs Manual, Richard Stallman.
237 cxref(1), emacs(1), vgrind(1), vi(1).
238
239
241 Copyright (c) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
242 Software Foundation, Inc.
243
244 Permission is granted to make and distribute verbatim copies of this
245 document provided the copyright notice and this permission notice are
246 preserved on all copies.
247
248 Permission is granted to copy and distribute modified versions of this
249 document under the conditions for verbatim copying, provided that the
250 entire resulting derived work is distributed under the terms of a per‐
251 mission notice identical to this one.
252
253 Permission is granted to copy and distribute translations of this docu‐
254 ment into another language, under the above conditions for modified
255 versions, except that this permission notice may be stated in a trans‐
256 lation approved by the Free Software Foundation.
257
258
259
260
261GNU Tools 23nov2001 etags(1)