1etags(1)                           GNU Tools                          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       Pascal, Perl, Ruby, PHP, PostScript, Python, Prolog,  Scheme  and  most
32       assembler-like  syntaxes.   Both  forms read the files specified on the
33       command line, and write a tag table (defaults: TAGS for etags, tags for
34       ctags) in the current working directory.  Files specified with relative
35       file names will be recorded in the tag table with file  names  relative
36       to  the  directory where the tag table resides.  If the tag table is in
37       /dev or is the standard output, however, the file names are made  rela‐
38       tive  to  the  working  directory.   Files specified with absolute file
39       names will be recorded with absolute file names.  Files generated  from
40       a source file--like a C file generated from a source Cweb file--will be
41       recorded with the name of the source file.  Compressed files  are  sup‐
42       ported  using gzip, bzip2, and xz.  The programs recognize the language
43       used in an input file based on its file name and contents.  The  --lan‐
44       guage  switch  can be used to force parsing of the file names following
45       the switch according to the given language, overriding guesses based on
46       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
69       -D, --no-defines
70              Do not create tag entries for C  preprocessor  constant  defini‐
71              tions  and  enum  constants.   This  may make the tags file much
72              smaller if many header files are tagged.
73
74       --globals
75              Create tag entries for global variables in  Perl  and  Makefile.
76              This is the default in C and derived languages.
77
78       --no-globals
79              Do  not  tag global variables in C and derived languages.  Typi‐
80              cally this reduces the file size by one fourth.
81
82       --no-line-directive
83              Ignore #line preprocessor directives in C and derived languages.
84              The default is to honor those directives, and record the tags as
85              if the file scanned was the one named in  the  #line  directive.
86              This  switch  is useful when the original file named by #line is
87              no longer available.
88
89       -i file, --include=file
90              Include a note in the tag file indicating that,  when  searching
91              for  a  tag,  one  should  also consult the tags file file after
92              checking the current file.  Only etags accepts this option.
93
94       -I, --ignore-indentation
95              Don't rely on indentation as much as we normally do.  Currently,
96              this  means not to assume that a closing brace in the first col‐
97              umn is the final brace of a function or structure definition  in
98              C and C++.
99
100       -l language, --language=language
101              Parse the following files according to the given language.  More
102              than one such options may be  intermixed  with  filenames.   Use
103              --help  to  get  a list of the available languages and their de‐
104              fault filename extensions.  The "auto" language can be  used  to
105              restore  automatic detection of language based on the file name.
106              The "none" language may be used to disable language parsing  al‐
107              together;  only  regexp  matching  is done in this case (see the
108              --regex option).
109
110       --members
111              Create tag entries for variables that are members of  structure-
112              like  constructs  in PHP.  This is the default for C and derived
113              languages.
114
115       --no-members
116              Do not tag member variables.
117
118       --packages-only
119              Only tag packages in Ada files.
120
121       --parse-stdin=file
122              May be used (only once) in place of a file name on  the  command
123              line.  etags will read from standard input and mark the produced
124              tags as belonging to the file FILE.
125
126        -Q, --class-qualify
127              Qualify tag names with their class name in C++, ObjC, Java,  and
128              Perl.  This produces tag names of the form class::member for C++
129              and Perl, class(category) for Objective C, and class.member  for
130              Java.   For Objective C, this also produces class methods quali‐
131              fied with their arguments, as in foo:bar:baz:more.
132
133       -o tagfile, --output=tagfile
134              Explicit name of file for tag table; for etags only, a file name
135              of  -  means  standard  output;  overrides default TAGS or tags.
136              (But ignored with -v or -x.)
137
138       -r regexp, --regex=regexp
139
140              Make tags based on regexp matching for the files following  this
141              option,  in  addition to the tags made with the standard parsing
142              based on language. May be freely intermixed with  filenames  and
143              the  -R option.  The regexps are cumulative, i.e., each such op‐
144              tion will add to the previous ones.  The regexps are of  one  of
145              the forms:
146                   [{language}]/tagregexp/[nameregexp/]modifiers
147                   @regexfile
148
149              where  tagregexp  is used to match the tag.  It should not match
150              useless characters.  If the match is such that  more  characters
151              than needed are unavoidably matched by tagregexp, it may be use‐
152              ful to add a nameregexp, to narrow down the  tag  scope.   ctags
153              ignores  regexps without a nameregexp.  The syntax of regexps is
154              the same as in emacs.  The following character escape  sequences
155              are supported: \a, \b, \d, \e, \f, \n, \r, \t, \v, which respec‐
156              tively stand for the ASCII characters BEL, BS, DEL, ESC, FF, NL,
157              CR, TAB, VT.
158              The  modifiers  are  a sequence of 0 or more characters among i,
159              which means to ignore case when matching; m,  which  means  that
160              the tagregexp will be matched against the whole file contents at
161              once, rather than line by line, and the  matching  sequence  can
162              match  multiple lines; and s, which implies m and means that the
163              dot character in tagregexp matches the newline char as well.
164              The separator, which is / in the examples, can be any  character
165              different from space, tab, braces and @.  If the separator char‐
166              acter is needed inside the regular expression, it must be quoted
167              by preceding it with \.
168              The optional {language} prefix means that the tag should be cre‐
169              ated only for files of language language, and ignored otherwise.
170              This is particularly useful when storing many predefined regexps
171              in a file.
172              In its second form, regexfile is the name of a  file  that  con‐
173              tains  a  number  of  arguments  to the --regex= option, one per
174              line.  Lines beginning with a space or tab  are  assumed  to  be
175              comments, and ignored.
176
177              Here  are  some examples.  All the regexps are quoted to protect
178              them from shell interpretation.
179
180              Tag the DEFVAR macros in the emacs source files:
181              --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
182
183              Tag VHDL files (this example is a single long line, broken  here
184              for formatting reasons):
185              --language=none --regex='/[ \t]*\(ARCHITECTURE\|\     CONFIGURA‐
186              TION\) +[^ ]* +OF/' --regex='/[ \t]*\ \(ATTRIBUTE\|ENTITY\|FUNC‐
187              TION\|PACKAGE\( BODY\)?\                                \|PROCE‐
188              DURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
189
190              Tag TCL files (this last example shows the usage  of  a  tagreg‐
191              exp):
192              --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
193
194              A regexp can be preceded by {lang}, thus restricting it to match
195              lines of files of the specified language.  Use etags  --help  to
196              obtain a list of the recognized languages.  This feature is par‐
197              ticularly useful inside regex files.  A regex file contains  one
198              regex  per  line.   Empty  lines, and those lines beginning with
199              space or tab are ignored.  Lines beginning with @ are references
200              to  regex  files whose name follows the @ sign.  Other lines are
201              considered regular expressions like those following --regex.
202              For example, the command
203              etags --regex=@regex.file *.c
204              reads the regexes contained in the file regex.file.
205
206       -R, --no-regex
207              Don't do any more regexp matching on the following  files.   May
208              be freely intermixed with filenames and the --regex option.
209
210       -u, --update
211              Update  tag entries for files specified on command line, leaving
212              tag entries for other files in place.  Currently, this is imple‐
213              mented  by deleting the existing entries for the given files and
214              then rewriting the new entries at the end of the tags file.   It
215              is  often  faster  to simply rebuild the entire tag file than to
216              use this.  Only ctags accepts this option.
217
218       -v, --vgrind
219              Instead of generating a tag file, write index (in vgrind format)
220              to standard output.  Only ctags accepts this option.
221
222       -x, --cxref
223              Instead  of  generating  a tag file, write a cross reference (in
224              cxref format) to standard output.  Only ctags accepts  this  op‐
225              tion.
226
227       -h, -H, --help
228              Print  usage  information.   Followed  by  one  or  more  --lan‐
229              guage=LANG prints detailed information about how tags are creat‐
230              ed for LANG.
231
232       -V, --version
233              Print the current version of the program (same as the version of
234              the emacs etags is shipped with).
235
236

SEE ALSO

238       "emacs" entry in info; GNU Emacs Manual, Richard Stallman.
239       cxref(1), emacs(1), vgrind(1), vi(1).
240
241

COPYING

243       Copyright 1992, 1999, 2001-2019 Free Software Foundation, Inc.
244
245       Permission is granted to make and distribute verbatim  copies  of  this
246       document  provided  the copyright notice and this permission notice are
247       preserved on all copies.
248
249       Permission is granted to copy and distribute modified versions of  this
250       document  under  the conditions for verbatim copying, provided that the
251       entire resulting derived work is distributed under the terms of a  per‐
252       mission notice identical to this one.
253
254       Permission is granted to copy and distribute translations of this docu‐
255       ment into another language, under the  above  conditions  for  modified
256       versions,  except that this permission notice may be stated in a trans‐
257       lation approved by the Free Software Foundation.
258
259
260
261GNU Tools                          23nov2001                          etags(1)
Impressum