1etags(1)                           GNU Tools                          etags(1)
2
3
4

NAME

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

SYNOPSIS

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

DESCRIPTION

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  and  bzip2.  The programs recognize the language used in an input
41       file based on its file name and contents.  The --language switch can be
42       used  to force parsing of the file names following the switch according
43       to the given language, overriding guesses based on filename extensions.
44

OPTIONS

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

SEE ALSO

221       `emacs' entry in info; GNU Emacs Manual, Richard Stallman.
222       cxref(1), emacs(1), vgrind(1), vi(1).
223
224

COPYING

226       Copyright  (C)  1992,  1999,  2001, 2002, 2003, 2004, 2005, 2006, 2007,
227       2008, 2009 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
245
246GNU Tools                          23nov2001                          etags(1)
Impressum