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