📄 ctags.html
字号:
Content-type: text/html<HTML><HEAD><TITLE>Manpage of CTAGS</TITLE></HEAD><BODY><H1>CTAGS</H1>Section: Exuberant Ctags (1)<BR>Updated: Version 5.5.4<BR><A HREF="#index">Index</A><A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR><P><P><A NAME="lbAB"> </A><H2>NAME</H2>ctags - Generate tag files for source code<P><P><A NAME="lbAC"> </A><H2>SYNOPSIS</H2><DL COMPACT><DT><B>ctags</B> [<B>options</B>] [<I>file(s)</I>]<DD><DT><B>etags</B> [<B>options</B>] [<I>file(s)</I>]<DD><P><P></DL><A NAME="lbAD"> </A><H2>DESCRIPTION</H2>The <B>ctags</B> and <B>etags</B> programs (hereinafter collectively referred toas <B>ctags</B>, except where distinguished) generate an index (or "tag") filefor a variety of language objects found in <I>file(s)</I>.This tag file allows these items to be quickly and easily located by a texteditor or other utility. A "tag" signifies a language object for which anindex entry is available (or, alternatively, the index entry created for thatobject).<P>Alternatively, <B>ctags</B> can generate a cross reference file which lists, inhuman readable form, information about the various source objects found in aset of language files.<P>Tag index files are supported by numerous editors, which allow the user tolocate the object associated with a name appearing in a source file and jumpto the file and line which defines the name. Those known about at the time ofthis release are:<P><DL COMPACT><DT><DD><B><A HREF="http://localhost/cgi-bin/man/man2html?1+Vi">Vi</A></B>(1) and its derivatives (e.g. Elvis, Vim, Vile, Lemmy),<B>CRiSP</B>,<B>Emacs</B>,<B>FTE</B> (Folding Text Editor),<B>JED</B>,<B>jEdit</B>,<B>Mined</B>,<B>NEdit</B> (Nirvana Edit),<B>TSE</B> (The SemWare Editor),<B>UltraEdit</B>,<B>WorkSpace</B>,<B>X2</B>,<B>Zeus</B></DL><P><B>Ctags</B> is capable of generating different kinds of tags for each of manydifferent languages. For a complete list of supported languages, the namesby which they are recognized, and the kinds of tags which are generated foreach, see the <B>--list-languages</B> and <B>--list-kinds</B> options.<P><P><A NAME="lbAE"> </A><H2>SOURCE FILES</H2><P>Unless the <B>--language-force</B> option is specified, the language of eachsource file is automatically selected based upon a mapping of file names tolanguages. The mappings in effect for each language may be display using the<B>--list-maps</B> option and may be changed using the <B>--langmap</B> option.On platforms which support it, if the name of a file is not mappedto a language and the file is executable, the first line of the file ischecked to see if the file is a "#!" script for a recognized language.<P>By default, all other files names are ignored. This permits running<B>ctags</B> on all files in either a single directory (e.g. "ctags *"), or onall files in an entire source directory tree (e.g. "ctags -R"), since onlythose files whose names are mapped to languages will be scanned.<P>[The reason that .h extensions are mapped to C++ files rather than C filesis because it is common to use .h extensions in C++, and no harm results intreating them as C++ files.]<P><P><A NAME="lbAF"> </A><H2>OPTIONS</H2><P>Despite the wealth of available options, defaults are set so that <B>ctags</B>is most commonly executed without any options (e.g. "ctags *", or "ctags -R"),which will create a tag file in the current directory for all recognizedsource files. The options described below are provided merely to allow customtailoring to meet special needs.<P>Note that spaces separating the single-letter options from their parametersare optional.<P>Note also that the boolean parameters to the long form options (thosebeginning with "--" and that take a "<I>[=yes</I>|<I>no]</I>" parameter) maybe omitted, in which case "<B>=</B><I>yes</I>" is implied. (e.g. <B>--sort</B>is equivalent to <B>--sort</B>=<I>yes</I>). Note further that "=<I>1</I>" and"=<I>on</I>" are considered synonyms for "=<I>yes</I>", and that "=<I>0</I>"and "=<I>off</I>" are considered synonyms for "=<I>no</I>".<P>Some options are either ignored or useful only when used while running inetags mode (see <B>-e</B> option). Such options will be noted.<P>Most options may appear anywhere on the command line, affecting only thosefiles which follow the option. A few options, however, must appear before thefirst file name and will be noted as such.<P>Options taking language names will accept those names in either upper or lowercase. See the <B>--list-languages</B> option for a complete list of thebuilt-in language names.<P><DL COMPACT><DT><B>-a</B><DD>Equivalent to <B>--append</B>.<P><DT><B>-B</B><DD>Use backward searching patterns (e.g. ?pattern?). [Ignored in etags mode]<P><DT><B>-e</B><DD>Enable etags mode, which will create a tag file for use with the Emacs editor.Alternatively, if <B>ctags</B> is invoked by a name containing the string"etags" (either by renaming, or creating a link to, the executable), etagsmode will be enabled. This option must appear before the first file name.<P><DT><B>-f</B><I> tagfile</I><DD>Use the name specified by <I>tagfile</I> for the tag file (default is "tags",or "TAGS" when running in etags mode). If <I>tagfile</I> is specified as"-", then the tag file is written to standard output instead. <B>Ctags</B>will stubbornly refuse to take orders if <I>tagfile</I> exists and its firstline contains something other than a valid tags line. This will save your neckif you mistakenly type "ctags -f *.c", which would otherwise overwrite yourfirst C file with the tags generated by the rest! It will also refuse toaccept a multi character file name which begins with a '-' (dash) character,since this most likely means that you left out the tag file name and thisoption tried to grab the next option as the file name. If you really want toname your output tag file "-ugly", specify it as "./-ugly". This option mustappear before the first file name. If this option is specified more than once,only the last will apply.<P><DT><B>-F</B><DD>Use forward searching patterns (e.g. /pattern/) (default).[Ignored in etags mode]<P><DT><B>-h</B><I> list</I><DD>Specifies a list of file extensions, separated by periods, which are to beinterpreted as include (or header) files. To indicate files having noextension, use a period not followed by a non-period character (e.g. ".","..x", ".x."). This option only affects how the scoping of a particular kindsof tags is interpreted (i.e. whether or not they are considered as globallyvisible or visible only within the file in which they are defined); it doesnot map the extension to any particular language. Any tag which is located ina non-include file and cannot be seen (e.g. linked to) from another file isconsidered to have file-limited (e.g. static) scope. No kind of tag appearingin an include file will be considered to have file-limited scope. If the firstcharacter in the list is a plus sign, then the extensions in the list will beappended to the current list; otherwise, the list will replace the currentlist. See, also, the <B>--file-scope</B> option. The default list is".h.H.hh.hpp.hxx.h++.inc.def". To restore the default list, specify <B>-h</B><I>default</I>. Note that if an extension supplied to this option is notalready mapped to a particular language (see <B>SOURCE FILES</B>, above), youwill also need to use either the <B>--langmap</B> or <B>--language-force</B>option.<P><DT><B>-I</B><I> identifier-list</I><DD>Specifies a list of identifiers which are to be specially handled whileparsing C and C++ source files. This option is specifically provided to handlespecial cases arising through the use of preprocessor macros. When theidentifiers listed are simple identifiers, these identifiers will be ignoredduring parsing of the source files. If an identifier is suffixed with a '+'character, <B>ctags</B> will also ignore any parenthesis-enclosed argument listwhich may immediately follow the identifier in the source files. If twoidentifiers are separated with the '=' character, the first identifiers isreplaced by the second identifiers for parsing purposes. The list ofidentifiers may be supplied directly on the command line or read in from aseparate file. If the first character of <I>identifier-list</I> is '@', '.' ora pathname separator ('/' or '\'), or the first two characters specify adrive letter (e.g. "C:"), the parameter <I>identifier-list</I> will beinterpreted as a filename from which to read a list of identifiers, one perinput line. Otherwise, <I>identifier-list</I> is a list of identifiers (oridentifier pairs) to be specially handled, each delimited by a either a commaor by white space (in which case the list should be quoted to keep the entirelist as one command line argument). Multiple <B>-I</B> options may be supplied.To clear the list of ignore identifiers, supply a single dash ("-") for<I>identifier-list</I>.<P>This feature is useful when preprocessor macros are used in such a way thatthey cause syntactic confusion due to their presence. Indeed, this is the bestway of working around a number of problems caused by the presence ofsyntax-busting macros in source files (see <B>CAVEATS</B>, below). Someexamples will illustrate this point.<P><DL COMPACT><DT><DD>int foo ARGDECL4(void *, ptr, long int, nbytes)</DL><P><DT><DD>In the above example, the macro "ARGDECL4" would be mistakenly interpreted tobe the name of the function instead of the correct name of "foo". Specifying<B>-I</B> <I>ARGDECL4</I> results in the correct behavior.<P><DL COMPACT><DT><DD>/* creates an RCS version string in module */<BR>MODULE_VERSION("$Revision: 1.38 $")</DL><P><DT><DD>In the above example the macro invocation looks too much like a functiondefinition because it is not followed by a semicolon (indeed, it could even befollowed by a global variable definition that would look much like a K&R stylefunction parameter declaration). In fact, this seeming function definitioncould possibly even cause the rest of the file to be skipped over while tryingto complete the definition. Specifying <B>-I</B> <I>MODULE_VERSION+</I> wouldavoid such a problem.<P><DL COMPACT><DT><DD>CLASS Example {<BR><BR> // your content here<BR>};</DL><P><DT><DD>The example above uses "CLASS" as a preprocessor macro which expands tosomething different for each platform. For instance CLASS may be defined as"class __declspec(dllexport)" on Win32 platforms and simply "class" on UNIX.Normally, the absence of the C++ keyword "class" would cause the source fileto be incorrectly parsed. Correct behavior can be restored by specifying<B>-I</B> <I>CLASS=class</I>.<P><DT><B>-L</B><I> file</I><DD>Read from <I>file</I> a list of file names for which tags should be generated.If <I>file</I> is specified as "-", then file names are read from standardinput. File names read using this option are processed following file namesappearing on the command line. Options all also accepted in this input. Ifthis option is specified more than once, only the last will apply. <B>Note:</B><I>file</I> is read in line-oriented mode, where a new line is the onlydelimiter and spaces are considered significant, in order that file namescontaining spaces may be supplied; this can affect how options are parsed ifincluded in the input.<P><DT><B>-n</B><DD>Equivalent to <B>--excmd</B>=<I>number</I>.<P><DT><B>-N</B><DD>Equivalent to <B>--excmd</B>=<I>pattern</I>.<P><DT><B>-o</B><I> tagfile</I><DD>Equivalent to <B>-f</B> <I>tagfile</I>.<P><DT><B>-R</B><DD>Equivalent to <B>--recurse</B>.<P><DT><B>-u</B><DD>Equivalent to <B>--sort</B>=<I>no</I> (i.e. "unsorted").<P><DT><B>-V</B><DD>Equivalent to <B>--verbose</B>.<P><DT><B>-w</B><DD>This option is silently ignored for backward-compatibility with the ctagsof SVR4 Unix.<P><DT><B>-x</B><DD>Print a tabular, human-readable cross reference (xref) file to standard outputinstead of generating a tag file. The information contained in the outputincludes: the tag name; the kind of tag; the line number, file name, andsource line (with extra white space condensed) of the file which defines thetag. No tag file is written and all options affecting tag file output will beignored. Example applications for this feature are generating a listing of allfunctions located in a source file (e.g. <B>ctags -x --c-kinds</B>=<I>f</I><I>file</I>), or generating a list of all externally visible global variableslocated in a source file (e.g. <B>ctags -x --c-kinds</B>=<I>v</I><B>--file-scope</B>=<I>no file</I>). This option must appear before the firstfile name.<P><DT><B>--append</B>[=<I>yes</I>|<I>no</I>]<DD>Indicates whether tags generated from the specified files should be appendedto those already present in the tag file or should replace them. This optionis off by default. This option must appear before the first file name.<P><DT><B>--etags-include</B>=<I>file</I><DD>Include a reference to <I>file</I> in the tag file. This option may bespecified as many times as desired. This supports Emacs' capability to use atag file which "includes" other tag files. [Available only in etags mode]<P><DT><B>--exclude</B>=[<I>pattern</I>]<DD>Add <I>pattern</I> to a list of excluded files and directories. This optionmay be specified as many times as desired. For each file name considered by
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -