1ETAGS(1)                              GNU                             ETAGS(1)
2
3
4

NAME

6       etags, ctags - generate tag file for Emacs, vi
7

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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++.  This is important for code that doesn't observe  the
102              GNU  Coding conventions of placing only top-level braces in col‐
103              umn zero.
104
105       -l language, --language=language
106              Parse the following files according to the given language.  More
107              than  one  such  options  may be intermixed with filenames.  Use
108              --help to get a list of the available languages  and  their  de‐
109              fault  filename  extensions.  For example, as Mercury and Objec‐
110              tive-C have same filename extension .m, a test based on contents
111              tries  to  detect  the  language.   If  this  test fails, --lan‐
112              guage=mercury or --language=objc should  be  used.   The  "auto"
113              language  can be used to restore automatic detection of language
114              based on the file name.  The "none" language may be used to dis‐
115              able  language  parsing altogether; only regexp matching is done
116              in this case (see the --regex option).
117
118       --members
119              Create tag entries for variables that are members of  structure-
120              like  constructs  in PHP.  This is the default for C and derived
121              languages.
122
123       --no-members
124              Do not tag member variables.
125
126       --packages-only
127              Only tag packages in Ada files.
128
129       --parse-stdin=file
130              May be used (only once) in place of a file name on  the  command
131              line.  etags will read from standard input and mark the produced
132              tags as belonging to the file FILE.
133
134       -Q, --class-qualify
135              Qualify tag names with their class name in C++, ObjC, Java,  and
136              Perl.  This produces tag names of the form class::member for C++
137              and Perl, class(category) for Objective C, and class.member  for
138              Java.   For Objective C, this also produces class methods quali‐
139              fied with their arguments, as in foo:bar:baz:more.
140
141       -o tagfile, --output=tagfile
142              Explicit name of file for tag table; for etags only, a file name
143              of  -  means  standard  output;  overrides default TAGS or tags.
144              (But ignored with -v or -x.)
145
146       -r regexp, --regex=regexp
147
148              Make tags based on regexp matching for the files following  this
149              option,  in  addition to the tags made with the standard parsing
150              based on language. May be freely intermixed with  filenames  and
151              the  -R option.  The regexps are cumulative, i.e., each such op‐
152              tion will add to the previous ones.  The regexps are of  one  of
153              the forms:
154                   [{language}]/tagregexp/[nameregexp/]modifiers
155                   @regexfile
156
157              where  tagregexp  is used to match the tag.  It should not match
158              useless characters.  If the match is such that  more  characters
159              than needed are unavoidably matched by tagregexp, it may be use‐
160              ful to add a nameregexp, to narrow down the  tag  scope.   ctags
161              ignores  regexps without a nameregexp.  The syntax of regexps is
162              the same as in emacs.  The following character escape  sequences
163              are supported: \a, \b, \d, \e, \f, \n, \r, \t, \v, which respec‐
164              tively stand for the ASCII characters BEL, BS, DEL, ESC, FF, NL,
165              CR, TAB, VT.
166              The  modifiers  are  a sequence of 0 or more characters among i,
167              which means to ignore case when matching; m,  which  means  that
168              the tagregexp will be matched against the whole file contents at
169              once, rather than line by line, and the  matching  sequence  can
170              match  multiple lines; and s, which implies m and means that the
171              dot character in tagregexp matches the newline char as well.
172              The separator, which is / in the examples, can be any  character
173              different from space, tab, braces and @.  If the separator char‐
174              acter is needed inside the regular expression, it must be quoted
175              by preceding it with \.
176              The optional {language} prefix means that the tag should be cre‐
177              ated only for files of language language, and ignored otherwise.
178              This is particularly useful when storing many predefined regexps
179              in a file.
180              In its second form, regexfile is the name of a  file  that  con‐
181              tains  a  number  of  arguments  to the --regex= option, one per
182              line.  Lines beginning with a space or tab  are  assumed  to  be
183              comments, and ignored.
184
185              Here  are  some examples.  All the regexps are quoted to protect
186              them from shell interpretation.
187
188              Tag the DEFVAR macros in the emacs source files:
189              --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
190
191              Tag VHDL files (this example is a single long line, broken  here
192              for formatting reasons):
193              --language=none --regex='/[ \t]*\(ARCHITECTURE\|\     CONFIGURA‐
194              TION\) +[^ ]* +OF/' --regex='/[ \t]*\ \(ATTRIBUTE\|ENTITY\|FUNC‐
195              TION\|PACKAGE\( BODY\)?\                                \|PROCE‐
196              DURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
197
198              Tag TCL files (this last example shows the usage  of  a  tagreg‐
199              exp):
200              --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
201
202              A regexp can be preceded by {lang}, thus restricting it to match
203              lines of files of the specified language.  Use etags  --help  to
204              obtain a list of the recognized languages.  This feature is par‐
205              ticularly useful inside regex files.  A regex file contains  one
206              regex  per  line.   Empty  lines, and those lines beginning with
207              space or tab are ignored.  Lines beginning with @ are references
208              to  regex  files whose name follows the @ sign.  Other lines are
209              considered regular expressions like those following --regex.
210              For example, the command
211              etags --regex=@regex.file *.c
212              reads the regexes contained in the file regex.file.
213
214       -R, --no-regex
215              Don't do any more regexp matching on the following  files.   May
216              be freely intermixed with filenames and the --regex option.
217
218       -u, --update
219              Update  tag entries for files specified on command line, leaving
220              tag entries for other files in place.  Currently, this is imple‐
221              mented  by deleting the existing entries for the given files and
222              then rewriting the new entries at the end of the tags file.   It
223              is  often  faster  to simply rebuild the entire tag file than to
224              use this.  Only ctags accepts this option.
225
226       -v, --vgrind
227              Instead of generating a tag file, write index (in vgrind format)
228              to standard output.  Only ctags accepts this option.
229
230       -x, --cxref
231              Instead  of  generating  a tag file, write a cross reference (in
232              cxref format) to standard output.  Only ctags accepts  this  op‐
233              tion.
234
235       -h, -H, --help
236              Print  usage  information.   Followed  by  one  or  more  --lan‐
237              guage=LANG prints detailed information about how tags are creat‐
238              ed for LANG.
239
240       -V, --version
241              Print the current version of the program (same as the version of
242              the emacs etags is shipped with).
243
244

SEE ALSO

246       "emacs" entry in info; GNU Emacs Manual, Richard Stallman.
247       cxref(1), emacs(1), vgrind(1), vi(1).
248
249

COPYING

251       Copyright 1992, 1999, 2001-2022 Free Software Foundation, Inc.
252
253       Permission is granted to make and distribute verbatim  copies  of  this
254       document  provided  the copyright notice and this permission notice are
255       preserved on all copies.
256
257       Permission is granted to copy and distribute modified versions of  this
258       document  under  the conditions for verbatim copying, provided that the
259       entire resulting derived work is distributed under the terms of a  per‐
260       mission notice identical to this one.
261
262       Permission is granted to copy and distribute translations of this docu‐
263       ment into another language, under the  above  conditions  for  modified
264       versions,  except that this permission notice may be stated in a trans‐
265       lation approved by the Free Software Foundation.
266
267
268
269
270GNU Tools                         2022-06-10                          ETAGS(1)
Impressum