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