1ctags(1) User Commands ctags(1)
2
3
4
6 ctags - create a tags file for use with ex and vi
7
9 /usr/bin/ctags [-aBFtuvwx] [-f tagsfile] file...
10
11
12 /usr/xpg4/bin/ctags [-aBFuvwx] [-f tagsfile] file...
13
14
16 The ctags utility makes a tags file for ex(1) from the specified C,
17 C++, Pascal, FORTRAN, yacc(1), and lex(1) sources. A tags file gives
18 the locations of specified objects (in this case functions and type‐
19 defs) in a group of files. Each line of the tags file contains the
20 object name, the file in which it is defined, and an address specifica‐
21 tion for the object definition. Functions are searched with a pattern,
22 typedefs with a line number. Specifiers are given in separate fields on
23 the line, separated by SPACE or TAB characters. Using the tags file, ex
24 can quickly find these objects' definitions.
25
26
27 Normally, ctags places the tag descriptions in a file called tags;
28 this may be overridden with the -f option.
29
30
31 Files with names ending in .c or .h are assumed to be either C or C++
32 source files and are searched for C/C++ routine and macro definitions.
33 Files with names ending in .cc, .C, or .cxx, are assumed to be C++
34 source files. Files with names ending in .y are assumed to be yacc
35 source files. Files with names ending in .l are assumed to be lex
36 files. Others are first examined to see if they contain any Pascal or
37 FORTRAN routine definitions; if not, they are processed again looking
38 for C definitions.
39
40
41 The tag main is treated specially in C or C++ programs. The tag formed
42 is created by prepending M to file, with a trailing .c , .cc .C, or
43 .cxx removed, if any, and leading path name components also removed.
44 This makes use of ctags practical in directories with more than one
45 program.
46
48 The precedence of the options that pertain to printing is -x, -v, then
49 the remaining options. The following options are supported:
50
51 -a Appends output to an existing tags file.
52
53
54 -B Uses backward searching patterns (?...?).
55
56
57 -f tagsfile Places the tag descriptions in a file called tagsfile
58 instead of tags.
59
60
61 -F Uses forward searching patterns (/.../) (default).
62
63
64 -t Creates tags for typedefs. /usr/xpg4/bin/ctags creates
65 tags for typedefs by default.
66
67
68 -u Updates the specified files in tags, that is, all refer‐
69 ences to them are deleted, and the new values are
70 appended to the file. Beware: this option is implemented
71 in a way that is rather slow; it is usually faster to
72 simply rebuild the tags file.
73
74
75 -v Produces on the standard output an index listing the
76 function name, file name, and page number (assuming 64
77 line pages). Since the output will be sorted into lexi‐
78 cographic order, it may be desired to run the output
79 through sort -f.
80
81
82 -w Suppresses warning diagnostics.
83
84
85 -x Produces a list of object names, the line number and
86 file name on which each is defined, as well as the text
87 of that line and prints this on the standard output.
88 This is a simple index which can be printed out as an
89 off-line readable function index.
90
91
93 The following file operands are supported:
94
95 file.c Files with basenames ending with the .c suffix are treated
96 as C-language source code.
97
98
99 file.h Files with basenames ending with the .h suffix are treated
100 as C-language source code.
101
102
103 file.f Files with basenames ending with the .f suffix are treated
104 as FORTRAN-language source code.
105
106
108 The -v option is mainly used with vgrind which will be part of the
109 optional BSD Compatibility Package.
110
112 Example 1 Producing entries in alphabetical order
113
114
115 Using ctags with the -v option produces entries in an order which may
116 not always be appropriate for vgrind. To produce results in alphabeti‐
117 cal order, you may want to run the output through sort -f.
118
119
120 example% ctags -v filename.c filename.h | sort -f > index
121 example% vgrind -x index
122
123
124
125 Example 2 Building a tags file
126
127
128 To build a tags file for C sources in a directory hierarchy rooted at
129 sourcedir, first create an empty tags file, and then run find(1)
130
131
132 example% cd sourcedir ; rm -f tags ; touch tags
133 example% find . \( -name SCCS -prune -name \\
134 '*.c' -o -name '*.h' \) -exec ctags -u {} \;
135
136
137
138
139 Notice that spaces must be entered exactly as shown.
140
141
143 See environ(5) for descriptions of the following environment variables
144 that affect the execution of ctags: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
145 LC_MESSAGES, and NLSPATH.
146
148 The following exit values are returned:
149
150 0 Successful completion.
151
152
153 >0 An error occurred.
154
155
157 tags output tags file
158
159
161 See attributes(5) for descriptions of the following attributes:
162
163 /usr/bin/ctags
164 ┌─────────────────────────────┬─────────────────────────────┐
165 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
166 ├─────────────────────────────┼─────────────────────────────┤
167 │Availability │SUNWtoo │
168 └─────────────────────────────┴─────────────────────────────┘
169
170 /usr/xpg4/bin/ctags
171 ┌─────────────────────────────┬─────────────────────────────┐
172 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
173 ├─────────────────────────────┼─────────────────────────────┤
174 │Availability │SUNWxcu4 │
175 ├─────────────────────────────┼─────────────────────────────┤
176 │Interface Stability │Standard │
177 └─────────────────────────────┴─────────────────────────────┘
178
180 ex(1), lex(1), vgrind(1), vi(1), yacc(1), attributes(5), environ(5),
181 standards(5)
182
184 Recognition of functions, subroutines, and procedures for FORTRAN and
185 Pascal is done in a very simpleminded way. No attempt is made to deal
186 with block structure; if you have two Pascal procedures in different
187 blocks with the same name, you lose.
188
189
190 The method of deciding whether to look for C or Pascal and FORTRAN
191 functions is a hack.
192
193
194 The ctags utility does not know about #ifdefs.
195
196
197 The ctags utility should know about Pascal types. Relies on the input
198 being well formed to detect typedefs. Use of -tx shows only the last
199 line of typedefs.
200
201
202
203SunOS 5.11 18 Mar 1997 ctags(1)