.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "ctags" 1 "" "6.1.0" "Universal Ctags" .SH NAME ctags \- Generate tag files for source code .SH SYNOPSIS .nf \fBctags\fP [] [] \fBetags\fP [] [] .fi .sp .SH DESCRIPTION .sp The \fIctags\fP and \fIetags\fP (see \fB\-e\fP option) programs (hereinafter collectively referred to as ctags, except where distinguished) generate an index (or \(dqtag\(dq) file for a variety of \fIlanguage objects\fP found in \fIsource file(s)\fP\&. This tag file allows these items to be quickly and easily located by a text editor or other utilities (\fIclient tools\fP). A \fItag\fP signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object). .sp Alternatively, ctags can generate a cross reference file which lists, in human readable form, information about the various language objects found in a set of source files. .sp Tag index files are supported by numerous editors, which allow the user to locate the object associated with a name appearing in a source file and jump to the file and line which defines the name. See the manual of your favorite editor about utilizing ctags command and the tag index files in the editor. .sp ctags is capable of generating different \fIkinds\fP of tags for each of many different \fIlanguages\fP\&. For a complete list of supported languages, the names by which they are recognized, and the kinds of tags which are generated for each, see the \fB\-\-list\-languages\fP and \fB\-\-list\-kinds\-full\fP options. .sp This man page describes \fIUniversal Ctags\fP, an implementation of ctags derived from \fIExuberant Ctags\fP\&. The major incompatible changes between Universal Ctags and Exuberant Ctags are enumerated in ctags\-incompatibilities(7). .sp One of the advantages of Exuberant Ctags is that it allows a user to define a new parser from the command line. Extending this capability is one of the major features of Universal Ctags. ctags\-optlib(7) describes how the capability is extended. .sp Newly introduced experimental features are not explained here. If you are interested in such features and ctags internals, visit \fI\%https://docs.ctags.io/\fP\&. .SH COMMAND LINE INTERFACE .sp Despite the wealth of available options, defaults are set so that ctags is most commonly executed without any options (e.g. \(dq\fBctags *\fP\(dq, or \(dq\fBctags \-R\fP\(dq), which will create a tag file in the current directory for all recognized source files. The options described below are provided merely to allow custom tailoring to meet special needs. .sp Note that spaces separating the single\-letter options from their parameters are optional. .sp Note also that the boolean parameters to the long form options (those beginning with \fB\-\-\fP and that take a \fB[=(yes|no)]\fP parameter) may be omitted, in which case \fB=yes\fP is implied. (e.g. \fB\-\-sort\fP is equivalent to \fB\-\-sort=yes\fP). Note further that \fB=1\fP, \fB=on\fP, and \fB=true\fP are considered synonyms for \fB=yes\fP, and that \fB=0\fP, \fB=off\fP, and \fB=false\fP are considered synonyms for \fB=no\fP\&. .sp Some options are either ignored or useful only when used while running in etags mode (see \fB\-e\fP option). Such options will be noted. .sp \fI\fP must precede the \fI\fP following the standard POSIX convention. .sp Options taking language names will accept those names in either upper or lower case. See the \fB\-\-list\-languages\fP option for a complete list of the built\-in language names. .SS Letters and names .sp Some options take one\-letter flags as parameters (e.g. \fB\-\-kinds\-\fP option). Specifying just letters help a user create a complicated command line quickly. However, a command line including sequences of one\-letter flags becomes difficult to understand. .sp Universal Ctags accepts long\-name flags in addition to such one\-letter flags. The long\-name and one\-letter flags can be mixed in an option parameter by surrounding each long\-name by braces. Thus, for an example, the following three notations for \fB\-\-kinds\-C\fP option have the same meaning: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-\-kinds\-C=+pLl \-\-kinds\-C=+{prototype}{label}{local} \-\-kinds\-C=+{prototype}L{local} .ft P .fi .UNINDENT .UNINDENT .sp Note that braces may be meta characters in your shell. Put single quotes in such case. .sp \fB\-\-list\-...\fP options shows one\-letter flags and associated long\-name flags. .SS List options .sp Universal Ctags introduces many \fB\-\-list\-...\fP options that provide the internal data of Universal Ctags (See \(dq\fI\%Listing Options\fP\(dq). Both users and client tools may use the data. \fB\-\-with\-list\-header\fP and \fB\-\-machinable\fP options adjust the output of the most of \fB\-\-list\-...\fP options. .sp The default setting (\fB\-\-with\-list\-header=yes\fP and \fB\-\-machinable=no\fP) is for using interactively from a terminal. The header that explains the meaning of columns is simply added to the output, and each column is aligned in all lines. The header line starts with a hash (\(aq\fB#\fP\(aq) character. .sp For scripting in a client tool, \fB\-\-with\-list\-header=no\fP and \fB\-\-machinable=yes\fP may be useful. The header is not added to the output, and each column is separated by tab characters. .sp Note the order of columns will change in the future release. However, labels in the header will not change. So by scanning the header, a client tool can find the index for the target column. .\" options that should be explained and revised here .\" ``--list-features`` (done) .\" ``--machinable`` (done) .\" ``--with-list-header`` (done) . .SH OPTIONS .sp ctags has more options than listed here. Options starting with an underscore character, such as \fB\-\-_echo=\fP, are not listed here. They are experimental or for debugging purpose. .sp Notation: \fB\fP is for a variable string \fBfoo\fP, \fB[ ... ]\fP for optional, \fB|\fP for selection, and \fB( ... )\fP for grouping. For example \fB\-\-foo[=(yes|no)]\(aq\(aq means \(ga\(ga\-\-foo\fP, \fB\-foo=yes\fP, or \fB\-foo=no\fP\&. .SS Input/Output File Options .INDENT 0.0 .TP .B \fB\-\-exclude=\fP Add \fI\fP to a list of excluded files and directories. This option may be specified as many times as desired. For each file name considered by ctags, each pattern specified using this option will be compared against both the complete path (e.g. \fBsome/path/base.ext\fP) and the base name (e.g. \fBbase.ext\fP) of the file, thus allowing patterns which match a given file name irrespective of its path, or match only a specific path. .sp If appropriate support is available from the runtime library of your C compiler, then pattern may contain the usual shell wildcards (not regular expressions) common on Unix (be sure to quote the option parameter to protect the wildcards from being expanded by the shell before being passed to ctags; also be aware that wildcards can match the slash character, \(aq\fB/\fP\(aq). You can determine if shell wildcards are available on your platform by examining the output of the \fB\-\-list\-features\fP option, which will include \fBwildcards\fP in the compiled feature list; otherwise, pattern is matched against file names using a simple textual comparison. .sp If \fI\fP begins with the character \(aq\fB@\fP\(aq, then the rest of the string is interpreted as a file name from which to read exclusion patterns, one per line. If pattern is empty, the list of excluded patterns is cleared. .sp Note that at program startup, the default exclude list contains names of common hidden and system files, patterns for binary files, and directories for which it is generally not desirable to descend while processing the \fB\-\-recurse\fP option. To see the list of built\-in exclude patterns, use \fB\-\-list\-excludes\fP\&. .sp See also the description for \fB\-\-exclude\-exception=\fP option. .TP .B \fB\-\-exclude\-exception=\fP Add \fI\fP to a list of included files and directories. The pattern affects the files and directories that are excluded by the pattern specified with \fB\-\-exclude=\fP option. .sp For an example, you want ctags to ignore all files under \fBfoo\fP directory except \fBfoo/main.c\fP, use the following command line: \fB\-\-exclude=foo/* \-\-exclude\-exception=foo/main.c\fP\&. .TP .B \fB\-\-filter[=(yes|no)]\fP Makes ctags behave as a filter, reading source file names from standard input and printing their tags to standard output on a file\-by\-file basis. If \fB\-\-sort\fP is enabled, tags are sorted only within the source file in which they are defined. File names are read from standard input in line\-oriented input mode (see note for \fB\-L\fP option) and only after file names listed on the command line or from any file supplied using the \fB\-L\fP option. When this option is enabled, the options \fB\-f\fP, \fB\-o\fP, and \fB\-\-totals\fP are ignored. This option is quite esoteric and is disabled by default. .TP .B \fB\-\-filter\-terminator=\fP Specifies a \fI\fP to print to standard output following the tags for each file name parsed when the \fB\-\-filter\fP option is enabled. This may permit an application reading the output of ctags to determine when the output for each file is finished. .sp Note that if the file name read is a directory and \fB\-\-recurse\fP is enabled, this string will be printed only once at the end of all tags found for by descending the directory. This string will always be separated from the last tag line for the file by its terminating newline. .sp This option is quite esoteric and is empty by default. .TP .B \fB\-\-links[=(yes|no)]\fP Indicates whether symbolic links (if supported) should be followed. When disabled, symbolic links are ignored. This option is on by default. .TP .B \fB\-\-maxdepth=\fP Limits the depth of directory recursion enabled with the \fB\-\-recurse\fP (\fB\-R\fP) option. .TP .B \fB\-\-recurse[=(yes|no)]\fP Recurse into directories encountered in the list of supplied files. .sp If the list of supplied files is empty and no file list is specified with the \fB\-L\fP option, then the current directory (i.e. \(aq\fB\&.\fP\(aq) is assumed. Symbolic links are followed by default (See \fB\-\-links\fP option). If you don\(aqt like these behaviors, either explicitly specify the files or pipe the output of \fBfind(1)\fP into \(dq\fBctags \-L \-\fP\(dq instead. See, also, the \fB\-\-exclude\fP and \fB\-\-maxdepth\fP to limit recursion. .sp Note: This option is not supported on all platforms at present. It is available if the output of the \fB\-\-help\fP option includes this option. .UNINDENT .\" TODO(code): --list-features option should support this. . .INDENT 0.0 .TP .B \fB\-R\fP Equivalent to \fB\-\-recurse\fP\&. .TP .B \fB\-L \fP Read from \fI\fP a list of file names for which tags should be generated. .sp If file is specified as \(aq\fB\-\fP\(aq, then file names are read from standard input. File names read using this option are processed following file names appearing on the command line. Options are also accepted in this input. If this option is specified more than once, only the last will apply. .sp Note: file is read in line\-oriented mode, where a new line is the only delimiter and non\-trailing white space is considered significant, in order that file names containing spaces may be supplied (however, trailing white space is stripped from lines); this can affect how options are parsed if included in the input. .TP .B \fB\-\-append[=(yes|no)]\fP Indicates whether tags generated from the specified files should be appended to those already present in the tag file or should replace them. This option is \fBno\fP by default. .TP .B \fB\-a\fP Equivalent to \fB\-\-append\fP\&. .TP .B \fB\-f \fP Use the name specified by \fI\fP for the tag file (default is \(dq\fBtags\fP\(dq, or \(dq\fBTAGS\fP\(dq when running in etags mode). If \fI\fP is specified as \(aq\fB\-\fP\(aq, then the tags are written to standard output instead. .sp ctags will stubbornly refuse to take orders if tagfile exists and its first line contains something other than a valid tags line. This will save your neck if you mistakenly type \(dq\fBctags \-f *.c\fP\(dq, which would otherwise overwrite your first C file with the tags generated by the rest! It will also refuse to accept a multi\-character file name which begins with a \(aq\fB\-\fP\(aq (dash) character, since this most likely means that you left out the tag file name and this option tried to grab the next option as the file name. If you really want to name your output tag file \fB\-ugly\fP, specify it as \(dq\fB\-f ./\-ugly\fP\(dq. .sp This option must appear before the first file name. If this option is specified more than once, only the last will apply. .TP .B \fB\-o \fP Equivalent to \(dq\fB\-f tagfile\fP\(dq. .UNINDENT .SS Output Format Options .INDENT 0.0 .TP .B \fB\-\-format=(1|2)\fP Change the format of the output tag file. Currently the only valid values for level are 1 or 2. Level 1 specifies the original tag file format and level 2 specifies a new extended format containing extension fields (but in a manner which retains backward\-compatibility with original \fBvi(1)\fP implementations). The default level is 2. [Ignored in etags mode] .TP .B \fB\-\-output\-format=(u\-ctags|e\-ctags|etags|xref|json)\fP Specify the output format. The default is \fBu\-ctags\fP\&. See tags(5) for \fBu\-ctags\fP and \fBe\-ctags\fP\&. \fBTAG_OUTPUT_MODE\fP pseudo tag indicates the choice, \fBu\-ctags\fP or \fBe\-ctags\fP\&. See ctags\-client\-tools(7) for more about the pseudo tag. .sp See \fB\-e\fP for \fBetags\fP, and \fB\-x\fP for \fBxref\fP\&. \fBjson\fP format is available only if the ctags executable is built with \fBlibjansson\fP\&. See ctags\-json\-output(5) for more about \fBjson\fP format. .TP .B \fB\-e\fP Same as \fB\-\-output\-format=etags\fP\&. Enable etags mode, which will create a tag file for use with the Emacs editor. Alternatively, if ctags is invoked by a name containing the string \(dqetags\(dq (either by renaming, or creating a link to, the executable), etags mode will be enabled. .TP .B \fB\-x\fP Same as \fB\-\-output\-format=xref\fP\&. Print a tabular, human\-readable cross reference (xref) file to standard output instead of generating a tag file. The information contained in the output includes: the tag name; the kind of tag; the line number, file name, and source line (with extra white space condensed) of the file which defines the tag. No tag file is written and all options affecting tag file output will be ignored. .sp Example applications for this feature are generating a listing of all functions located in a source file (e.g. \(dq\fBctags \-x \-\-kinds\-c=f file\fP\(dq), or generating a list of all externally visible global variables located in a source file (e.g. \(dq\fBctags \-x \-\-kinds\-c=v \-\-extras=\-F file\fP\(dq). .TP .B \fB\-\-sort=(yes|no|foldcase)\fP Indicates whether the tag file should be sorted on the tag name (default is \fByes\fP). Note that the original \fBvi(1)\fP required sorted tags. The \fBfoldcase\fP value specifies case insensitive (or case\-folded) sorting. Fast binary searches of tag files sorted with case\-folding will require special support from tools using tag files, such as that found in the ctags readtags library, or Vim version 6.2 or higher (using \(dq\fBset ignorecase\fP\(dq). [Ignored in etags mode] .TP .B \fB\-u\fP Equivalent to \fB\-\-sort=no\fP (i.e. \(dqunsorted\(dq). .TP .B \fB\-\-etags\-include=\fP Include a reference to \fI\fP in the tag file. This option may be specified as many times as desired. This supports Emacs\(aq capability to use a tag file which \fIincludes\fP other tag files. [Available only in etags mode] .TP .B \fB\-\-input\-encoding=\fP Specifies the \fI\fP of the input files. If this option is specified, Universal Ctags converts the input from this encoding to the encoding specified by \fB\-\-output\-encoding=encoding\fP\&. .TP .B \fB\-\-input\-encoding\-=\fP Specifies a specific input \fI\fP for \fI\fP\&. It overrides the global default value given with \fB\-\-input\-encoding\fP\&. .TP .B \fB\-\-output\-encoding=\fP Specifies the \fI\fP of the tags file. Universal Ctags converts the encoding of input files from the encoding specified by \fB\-\-input\-encoding=\fP to this encoding. .sp In addition \fI\fP is specified at the top the tags file as the value for the \fBTAG_FILE_ENCODING\fP pseudo\-tag. The default value of \fI\fP is \fBUTF\-8\fP\&. .UNINDENT .SS Language Selection and Mapping Options .INDENT 0.0 .TP .B \fB\-\-language\-force=(|auto)\fP By default, ctags automatically selects the language of a source file, ignoring those files whose language cannot be determined (see \(dq\fI\%Determining file language\fP\(dq). This option forces the specified \fIlanguage\fP (case\-insensitive; either built\-in or user\-defined) to be used for every supplied file instead of automatically selecting the language based upon its extension. .sp In addition, the special value \fBauto\fP indicates that the language should be automatically selected (which effectively disables this option). .TP .B \fB\-\-languages=[+|\-](|all)\fP Specifies the languages for which tag generation is enabled, with \fI\fP containing a comma\-separated list of language names (case\-insensitive; either built\-in or user\-defined). .sp If the first language of \fI\fP is not preceded by either a \(aq\fB+\fP\(aq or \(aq\fB\-\fP\(aq, the current list (the current settings of enabled/disabled languages managed in ctags internally) will be cleared before adding or removing the languages in \fI\fP\&. Until a \(aq\fB\-\fP\(aq is encountered, each language in the \fI\fP will be added to the current list. .sp As either the \(aq\fB+\fP\(aq or \(aq\fB\-\fP\(aq is encountered in the \fI\fP, the languages following it are added or removed from the current list, respectively. Thus, it becomes simple to replace the current list with a new one, or to add or remove languages from the current list. .sp The actual list of files for which tags will be generated depends upon the language extension mapping in effect (see the \fB\-\-langmap\fP option). Note that the most of languages, including user\-defined languages, are enabled unless explicitly disabled using this option. Language names included in list may be any built\-in language or one previously defined with \fB\-\-langdef\fP\&. .sp The default is \fBall\fP, which is also accepted as a valid argument. See the \fB\-\-list\-languages\fP option for a list of the all (built\-in and user\-defined) language names. .sp Note \fB\-\-languages=\fP option works cumulative way; the option can be specified with different arguments multiple times in a command line. .TP .B \fB\-\-alias\-=[+|\-](|default)\fP Adds (\(aq\fB+\fP\(aq) or removes (\(aq\fB\-\fP\(aq) an alias \fI\fP to a language specified with \fI\fP\&. ctags refers to the alias pattern in \(dq\fI\%Determining file language\fP\(dq stage. .sp The parameter \fI\fP is not a list. Use this option multiple times in a command line to add or remove multiple alias patterns. .sp To restore the default language aliases, specify \fBdefault\fP\&. .sp Using \fBall\fP for \fI\fP has meaning in following two cases: .INDENT 7.0 .TP .B \fB\-\-alias\-all=\fP This clears aliases setting of all languages. .TP .B \fB\-\-alias\-all=default\fP This restores the default languages aliases for all languages. .UNINDENT .TP .B \fB\-\-guess\-language\-eagerly\fP Looks into the file contents for heuristically guessing the proper language parser. See \(dq\fI\%Determining file language\fP\(dq. .TP .B \fB\-G\fP Equivalent to \fB\-\-guess\-language\-eagerly\fP\&. .TP .B \fB\-\-langmap=[,[...]]\fP Controls how file names are mapped to languages (see the \fB\-\-list\-maps\fP option). Each comma\-separated \fI\fP consists of the language name (either a built\-in or user\-defined language), a colon, and a list of \fIfile extensions\fP and/or \fIfile name patterns\fP\&. A file extension is specified by preceding the extension with a period (e.g. \fB\&.c\fP). A file name pattern is specified by enclosing the pattern in parentheses (e.g. \fB([Mm]akefile)\fP). .sp If appropriate support is available from the runtime library of your C compiler, then the file name pattern may contain the usual shell wildcards common on Unix (be sure to quote the option parameter to protect the wildcards from being expanded by the shell before being passed to ctags). You can determine if shell wildcards are available on your platform by examining the output of the \fB\-\-list\-features\fP option, which will include \fBwildcards\fP in the compiled feature list; otherwise, the file name patterns are matched against file names using a simple textual comparison. .sp When mapping a file extension with \fB\-\-langmap\fP option, it will first be unmapped from any other languages. (\fB\-\-map\-\fP option provides more fine\-grained control.) .sp If the first character in a \fI\fP is a plus sign (\(aq\fB+\fP\(aq), then the extensions and file name patterns in that map will be appended to the current map for that language; otherwise, the map will replace the current map. For example, to specify that only files with extensions of \fB\&.c\fP and \fB\&.x\fP are to be treated as C language files, use \fB\-\-langmap=c:.c.x\fP; to also add files with extensions of \fB\&.j\fP as Java language files, specify \fB\-\-langmap=c:.c.x,java:+.j\fP\&. To map makefiles (e.g. files named either \fBMakefile\fP, \fBmakefile\fP, or having the extension \fB\&.mak\fP) to a language called \fBmake\fP, specify \fB\-\-langmap=make:([Mm]akefile).mak\fP\&. To map files having no extension, specify a period not followed by a non\-period character (e.g. \(aq\fB\&.\fP\(aq, \fB\&..x\fP, \fB\&.x.\fP). .sp To clear the mapping for a particular language (thus inhibiting automatic generation of tags for that language), specify an empty extension list (e.g. \fB\-\-langmap=fortran:\fP). To restore the default language mappings for a particular language, supply the keyword \fBdefault\fP for the mapping. To specify restore the default language mappings for all languages, specify \fB\-\-langmap=default\fP\&. .sp Note that file name patterns are tested before file extensions when inferring the language of a file. This order of Universal Ctags is different from Exuberant Ctags. See ctags\-incompatibilities(7) for the background of this incompatible change. .TP .B \fB\-\-map\-=[+|\-]|\fP This option provides the way to control mapping(s) of file names to languages in a more fine\-grained way than \fB\-\-langmap\fP option. .sp In ctags, more than one language can map to a file name \fI\fP or file \fI\fP (\fIN:1 map\fP). Alternatively, \fB\-\-langmap\fP option handle only \fI1:1 map\fP, only one language mapping to one file name \fI\fP or file \fI\fP\&. A typical N:1 map is seen in C++ and ObjectiveC language; both languages have a map to \fB\&.h\fP as a file extension. .sp A file extension is specified by preceding the extension with a period (e.g. \fB\&.c\fP). A file name pattern is specified by enclosing the pattern in parentheses (e.g. \fB([Mm]akefile)\fP). A prefixed plus (\(aq\fB+\fP\(aq) sign is for adding, and minus (\(aq\fB\-\fP\(aq) is for removing. No prefix means replacing the map of \fI\fP\&. .sp Unlike \fB\-\-langmap\fP, \fI\fP (or \fI\fP) is not a list. \fB\-\-map\-\fP takes one extension (or pattern). However, the option can be specified with different arguments multiple times in a command line. .UNINDENT .SS Tags File Contents Options .sp See \(dq\fI\%TAG ENTRIES\fP\(dq about fields, kinds, roles, and extras. .INDENT 0.0 .TP .B \fB\-\-excmd=(number|pattern|mix|combine)\fP Determines the type of \fBEX\fP command used to locate tags in the source file. [Ignored in etags mode] .sp The valid values for type (either the entire word or the first letter is accepted) are: .INDENT 7.0 .TP .B \fBnumber\fP Use only line numbers in the tag file for locating tags. This has four advantages: .INDENT 7.0 .IP 1. 3 Significantly reduces the size of the resulting tag file. .IP 2. 3 Eliminates failures to find tags because the line defining the tag has changed, causing the pattern match to fail (note that some editors, such as \fBvim\fP, are able to recover in many such instances). .IP 3. 3 Eliminates finding identical matching, but incorrect, source lines (see \(dq\fI\%BUGS\fP\(dq). .IP 4. 3 Retains separate entries in the tag file for lines which are identical in content. In pattern mode, duplicate entries are dropped because the search patterns they generate are identical, making the duplicate entries useless. .UNINDENT .sp However, this option has one significant drawback: changes to the source files can cause the line numbers recorded in the tag file to no longer correspond to the lines in the source file, causing jumps to some tags to miss the target definition by one or more lines. Basically, this option is best used when the source code to which it is applied is not subject to change. Selecting this option type causes the following options to be ignored: \fB\-B\fP, \fB\-F\fP\&. .sp \fBnumber\fP type is ignored in Xref and JSON output formats. Use \fB\-\-_xformat=\(dq...%n\(dq\fP for Xref output format, or \fB\-\-fields=+n\-P\fP for JSON output format. .\" NOTE: #2792 . .TP .B \fBpattern\fP Use only search patterns for all tags, rather than the line numbers usually used for macro definitions. This has the advantage of not referencing obsolete line numbers when lines have been added or removed since the tag file was generated. .TP .B \fBmixed\fP In this mode, patterns are generally used with an exceptions. For Fortran, line numbers are used for common blocks because their corresponding source lines are generally identical, making pattern searches useless for finding all matches. .sp Exuberant Ctags has one more exception; for C, line numbers are used for macro definition tags. Universal Ctags doesn\(aqt have this exception for C. .sp This was the default format generated by the original ctags and is, therefore, retained as the default for this option. .TP .B \fBcombine\fP Concatenate the line number and pattern with a semicolon in between. .UNINDENT .TP .B \fB\-n\fP Equivalent to \fB\-\-excmd=number\fP\&. .TP .B \fB\-N\fP Equivalent to \fB\-\-excmd=pattern\fP\&. .TP .B \fB\-\-extras=[+|\-][|*]\fP Specifies whether to include extra tag entries for certain kinds of information. See also \(dq\fI\%Extras\fP\(dq subsection to know what are extras. .sp The parameter \fI\fP is a set of one\-letter flags (and/or long\-name flags), each representing one kind of extra tag entry to include in the tag file. If flags is preceded by either the \(aq\fB+\fP\(aq or \(aq\fB\-\fP\(aq character, the effect of each flag is added to, or removed from, those currently enabled; otherwise the flags replace any current settings. All entries are included if \(aq\fB*\fP\(aq is given. .sp This \fB\-\-extras=\fP option is for controlling extras common in all languages (or language\-independent extras). Universal Ctags also supports language\-specific extras. (See \(dq\fI\%Language\-specific fields and extras\fP\(dq about the concept). Use \fB\-\-extras\-=\fP option for controlling them. .TP .B \fB\-\-extras\-(|all)=[+|\-][|*]\fP Specifies whether to include extra tag entries for certain kinds of information for language \fI\fP\&. Universal Ctags introduces language\-specific extras. See \(dq\fI\%Language\-specific fields and extras\fP\(dq about the concept. This option is for controlling them. .sp Specifies \fBall\fP as \fI\fP to apply the parameter \fI\fP to all languages; all extras are enabled with specifying \(aq\fB*\fP\(aq as the parameter flags. If specifying nothing as the parameter flags (\fB\-\-extras\-all=\fP), all extras are disabled. These two combinations are useful for testing. .sp Check the output of the \fB\-\-list\-extras=\fP option for the extras of specific language \fI\fP\&. .TP .B \fB\-\-fields=[+|\-][|*]\fP Specifies which language\-independent fields are to be included in the tag entries. Language\-independent fields are extension fields which are common in all languages. See \(dq\fI\%TAG FILE FORMAT\fP\(dq section, and \(dq\fI\%Extension fields\fP\(dq subsection, for details of extension fields. .sp The parameter \fI\fP is a set of one\-letter or long\-name flags, each representing one type of extension field to include. Each flag or group of flags may be preceded by either \(aq\fB+\fP\(aq to add it to the default set, or \(aq\fB\-\fP\(aq to exclude it. In the absence of any preceding \(aq\fB+\fP\(aq or \(aq\fB\-\fP\(aq sign, only those fields explicitly listed in flags will be included in the output (i.e. overriding the default set). All fields are included if \(aq\fB*\fP\(aq is given. .sp This option is ignored if the option \fB\-\-format=1\fP (legacy tag file format) has been specified. .sp Use \fB\-\-fields\-=\fP option for controlling language\-specific fields. .TP .B \fB\-\-fields\-(|all)=[+|\-][|*]\fP Specifies which language\-specific fields are to be included in the tag entries. Universal Ctags supports language\-specific fields. (See \(dq\fI\%Language\-specific fields and extras\fP\(dq about the concept). .sp Specify \fBall\fP as \fI\fP to apply the parameter \fI\fP to all languages; all fields are enabled with specifying \(aq\fB*\fP\(aq as the parameter flags. If specifying nothing as the parameter \fI\fP (i.e. \fB\-\-fields\-all=\fP), all fields are disabled. These two combinations are useful for testing. .sp See the description of \fB\-\-fields=[+|\-][|*]\fP about \fI\fP\&. .sp Use \fB\-\-fields=\fP option for controlling language\-independent fields. .TP .B \fB\-\-kinds\-(|all)=[+|\-](|*)\fP Specifies a list of language\-specific \fI\fP of tags (or kinds) to include in the output file for a particular language, where \fI\fP is case\-insensitive and is one of the built\-in language names (see the \fB\-\-list\-languages\fP option for a complete list). .sp The parameter \fI\fP is a group of one\-letter or long\-name flags designating kinds of tags (particular to the language) to either include or exclude from the output. The specific sets of flags recognized for each language, their meanings and defaults may be list using the \fB\-\-list\-kinds\-full\fP option. .sp Each letter or group of letters may be preceded by either \(aq\fB+\fP\(aq to add it to, or \(aq\fB\-\fP\(aq to remove it from, the default set. In the absence of any preceding \(aq\fB+\fP\(aq or \(aq\fB\-\fP\(aq sign, only those kinds explicitly listed in kinds will be included in the output (i.e. overriding the default for the specified language). .sp Specify \(aq\fB*\fP\(aq as the parameter to include all kinds implemented in \fI\fP in the output. Furthermore if \fBall\fP is given as \fI\fP, specification of the parameter \fBkinds\fP affects all languages defined in ctags. Giving \fBall\fP makes sense only when \(aq\fB*\fP\(aq or \(aq\fBF\fP\(aq is given as the parameter \fBkinds\fP\&. .sp As an example for the C language, in order to add prototypes and external variable declarations to the default set of tag kinds, but exclude macros, use \fB\-\-kinds\-c=+px\-d\fP; to include only tags for functions, use \fB\-\-kinds\-c=f\fP\&. .sp Some kinds of C and C++ languages are synchronized; enabling (or disabling) a kind in one language enables the kind having the same one\-letter and long\-name in the other language. See also the description of \fBMASTER\fP column of \fB\-\-list\-kinds\-full\fP\&. .UNINDENT .\" COMMENT: .\" ``--param-.name=argument`` is moved to "Language Specific Options" . .INDENT 0.0 .TP .B \fB\-\-pattern\-length\-limit=\fP Truncate patterns of tag entries after \fI\fP characters. Disable by setting to 0 (default is 96). .sp An input source file with long lines and multiple tag matches per line can generate an excessively large tags file with an unconstrained pattern length. For example, running ctags on a minified JavaScript source file often exhibits this behavior. .sp The truncation avoids cutting in the middle of a UTF\-8 code point spanning multiple bytes to prevent writing invalid byte sequences from valid input files. This handling allows for an extra 3 bytes above the configured limit in the worse case of a 4 byte code point starting right before the limit. Please also note that this handling is fairly naive and fast, and although it is resistant against any input, it requires a valid input to work properly; it is not guaranteed to work as the user expects when dealing with partially invalid UTF\-8 input. This also partially affect non\-UTF\-8 input, if the byte sequence at the truncation length looks like a multibyte UTF\-8 sequence. This should however be rare, and in the worse case will lead to including up to an extra 3 bytes above the limit. .TP .B \fB\-\-pseudo\-tags=[+|\-](|*)\fP Enable/disable emitting pseudo\-tag named \fI\fP\&. If \(aq\fB*\fP\(aq is given, enable/disable emitting all pseudo\-tags. .TP .B \fB\-\-put\-field\-prefix\fP Put \fBUCTAGS\fP as prefix for the name of fields newly introduced in Universal Ctags. .sp Some fields are newly introduced in Universal Ctags and more will be introduced in the future. Other tags generators may also introduce their specific fields. .sp In such a situation, there is a concern about conflicting field names; mixing tags files generated by multiple tags generators including Universal Ctags is difficult. This option provides a workaround for such station. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-fields=\(aq{line}{end}\(aq \-o \- hello.c main hello.c /^main(int argc, char **argv)$/;\(dq f line:3 end:6 $ ctags \-\-put\-field\-prefix \-\-fields=\(aq{line}{end}\(aq \-o \- hello.c main hello.c /^main(int argc, char **argv)$/;\(dq f line:3 UCTAGSend:6 .ft P .fi .UNINDENT .UNINDENT .sp In the above example, the prefix is put to \fBend\fP field which is newly introduced in Universal Ctags. .TP .B \fB\-\-roles\-(|all).(|*)=[+|\-][|*]\fP Specifies a list of kind\-specific roles of tags to include in the output file for a particular language. \fI\fP specifies the kind where the \fI\fP are defined. \fI\fP specifies the language where the kind is defined. Each role in \fI\fP must be surrounded by braces (e.g. \fB{system}\fP for a role named \(dqsystem\(dq). .sp Like \fB\-\-kinds\-\fP option, \(aq\fB+\fP\(aq is for adding the role to the list, and \(aq\fB\-\fP\(aq is for removing from the list. \(aq\fB*\fP\(aq is for including all roles of the kind to the list. The option with no argument makes the list empty. .sp Both a one\-letter flag or a long name flag surrounded by braces are acceptable for specifying a kind (e.g. \fB\-\-roles\-C.h=+{system}{local}\fP or \fB\-\-roles\-C.{header}=+{system}{local}\fP). \(aq\fB*\fP\(aq can be used for \fI\fP only for adding/removing all roles of all kinds in a language to/from the list (e.g. \fB\-\-roles\-C.*=*\fP or \fB\-\-roles\-C.*=\fP). .sp \fBall\fP can be used for \fI\fP only for adding/removing all roles of all kinds in all languages to/from the list (e.g. \fB\-\-roles\-all.*=*\fP or \fB\-\-roles\-all.*=\fP). .TP .B \fB\-\-tag\-relative=(yes|no|always|never)\fP Specifies how the file paths recorded in the tag file. The default is \fByes\fP when running in etags mode (see the \fB\-e\fP option), \fBno\fP otherwise. .INDENT 7.0 .TP .B \fByes\fP indicates that the file paths recorded in the tag file should be \fIrelative to the directory containing the tag file\fP unless the files supplied on the command line are specified with absolute paths. .TP .B \fBno\fP indicates that the file paths recorded in the tag file should be \fIrelative to the current directory\fP unless the files supplied on the command line are specified with absolute paths. .TP .B \fBalways\fP indicates the recorded file paths should be relative even if source file names are passed in with absolute paths. .TP .B \fBnever\fP indicates the recorded file paths should be absolute even if source file names are passed in with relative paths. .UNINDENT .TP .B \fB\-\-use\-slash\-as\-filename\-separator[=(yes|no)]\fP Uses slash (\(aq\fB/\fP\(aq) character as filename separators instead of backslash (\(aq\fB\e\fP\(aq) character when printing \fBinput:\fP field. The default is \fByes\fP for the default \(dqu\-ctags\(dq output format, and \fBno\fP for the other formats. .sp \fBTAG_OUTPUT_FILESEP\fP pseudo tag is for representing the choice of filename separators with this option. See also ctags\-client\-tools(7). .sp This option is available on MS Windows only. .TP .B \fB\-B\fP Use backward searching patterns (e.g. \fB?pattern?\fP). [Ignored in etags mode] .TP .B \fB\-F\fP Use forward searching patterns (e.g. \fB/pattern/\fP) (default). [Ignored in etags mode] .UNINDENT .SS Option File Options .\" TODO: merge some of description in option-file.rst into FILE or a dedicated .\" section . .INDENT 0.0 .TP .B \fB\-\-options=\fP Read additional options from file or directory. .sp ctags searches \fI\fP in the optlib path list first. If ctags cannot find a file or directory in the list, ctags reads a file or directory at the specified \fI\fP\&. .sp If a file is specified, it should contain one option per line. If a directory is specified, files suffixed with \fB\&.ctags\fP under it are read in alphabetical order. .sp As a special case, if \fB\-\-options=NONE\fP is specified as the first option on the command line, preloading is disabled; the option will disable the automatic reading of any configuration options from a file (see \(dq\fI\%FILES\fP\(dq). .TP .B \fB\-\-options\-maybe=\fP Same as \fB\-\-options\fP but doesn\(aqt cause an error if file (or directory) specified with \fI\fP doesn\(aqt exist. .TP .B \fB\-\-optlib\-dir=[+]\fP Add an optlib \fI\fP to or reset the optlib path list. See \(dq\fI\%Default optlib path list\fP\(dq about the default elements for optlib path list. .UNINDENT .SS optlib Options .sp See ctags\-optlib(7) for details of each option. .INDENT 0.0 .TP .B \fB\-\-kinddef\-=,,\fP Define a kind for \fI\fP\&. Don\(aqt be confused this with \fB\-\-kinds\-\fP\&. .TP .B \fB\-\-langdef=\fP Defines a new user\-defined language, \fI\fP, to be parsed with regular expressions. .TP .B \fB\-\-mline\-regex\-=////[]\fP Define multi\-line regular expression for locating tags in specific language. .TP .B \fB\-\-regex\-=////[]\fP Define single\-line regular expression for locating tags in specific language. .UNINDENT .SS Language Specific Options .INDENT 0.0 .TP .B \fB\-\-if0[=(yes|no)]\fP Indicates a preference as to whether code within an \(dq\fB#if 0\fP\(dq branch of a preprocessor conditional should be examined for non\-macro tags (macro tags are always included). Because the intent of this construct is to disable code, the default value of this option is \fBno\fP (disabled). .sp Note that this indicates a preference only and does not guarantee skipping code within an \(dq\fB#if 0\fP\(dq branch, since the fall\-back algorithm used to generate tags when preprocessor conditionals are too complex follows all branches of a conditional. .TP .B \fB\-\-line\-directives[=(yes|no)]\fP Specifies whether \fB#line\fP directives should be recognized. These are present in the output of a preprocessor and contain the line number, and possibly the file name, of the original source file(s) from which the preprocessor output file was generated. This option is off by default. .sp When enabled, this option will cause ctags to generate tag entries marked with the file names and line numbers of their locations original source file(s), instead of their actual locations in the preprocessor output. The actual file names placed into the tag file will have the same leading path components as the preprocessor output file, since it is assumed that the original source files are located relative to the preprocessor output file (unless, of course, the \fB#line\fP directive specifies an absolute path). .sp Note: This option is generally only useful when used together with the \fB\-\-excmd=number\fP (\fB\-n\fP) option. Also, you may have to use either the \fB\-\-langmap\fP or \fB\-\-language\-force\fP option if the extension of the preprocessor output file is not known to ctags. .TP .B \fB\-D =\fP Defines a C preprocessor \fI\fP\&. This emulates the behavior of the corresponding gcc option. All types of macros are supported, including the ones with parameters and variable arguments. Stringification, token pasting and recursive macro expansion are also supported. This extends the function provided by \fB\-I\fP option. .TP .B \fB\-h (|default)\fP Specifies a \fI\fP of file extensions, separated by periods, which are to be interpreted as include (or header) files. To indicate files having no extension, use a period not followed by a non\-period character (e.g. \(aq\fB\&.\fP\(aq, \fB\&..x\fP, \fB\&.x.\fP). .sp This option only affects how the scoping of particular kinds of tags are interpreted (i.e. whether or not they are considered as globally visible or visible only within the file in which they are defined); it does not map the extension to any particular language. Any tag which is located in a non\-include file and cannot be seen (e.g. linked to) from another file is considered to have file\-limited (e.g. static) scope. No kind of tag appearing in an include file will be considered to have file\-limited scope. .sp If the first character in the list is \(aq\fB+\fP\(aq, then the extensions in the list will be appended to the current list; otherwise, the list will replace the current list. See, also, the \fBfileScope\fP/\fBF\fP flag of \fB\-\-extras\fP option. .sp The default list is \fB\&.h.H.hh.hpp.hxx.h++.inc.def\fP\&. To restore the default list, specify \(dq\fB\-h default\fP\(dq. .sp Note that if an extension supplied to this option is not already mapped to a particular language (see \(dq\fI\%Determining file language\fP\(dq, above), you will also need to use either the \fB\-\-map\-\fP, \fB\-\-langmap\fP or \fB\-\-language\-force\fP option. .TP .B \fB\-I \fP Specifies a \fI\fP of identifiers which are to be specially handled while parsing C and C++ source files. This option is specifically provided to handle special cases arising through the use of preprocessor macros. When the identifiers listed are simple identifiers, these identifiers will be ignored during parsing of the source files. .sp If an identifier is suffixed with a \(aq\fB+\fP\(aq character (i.e. \(dq\fB\-I FOO+\fP\(dq), ctags will also ignore any parenthesis\-enclosed argument list which may immediately follow the identifier in the source files. See the example of \(dq\fB\-I MODULE_VERSION+\fP\(dq below. .sp If two identifiers are separated with the \(aq\fB=\fP\(aq character (i.e. \fB\-I FOO=BAR\fP), the first identifiers is replaced by the second identifiers for parsing purposes. The list of identifiers may be supplied directly on the command line or read in from a separate file. See the example of \(dq\fB\-I CLASS=class\fP\(dq below. .sp If the first character of \fI\fP is \(aq\fB@\fP\(aq, \(aq\fB\&.\fP\(aq or a pathname separator (\(aq\fB/\fP\(aq or \(aq\fB\e\fP\(aq), or the first two characters specify a drive letter (e.g. \fBC:\fP), the parameter \fI\fP will be interpreted as a filename from which to read a list of identifiers, one per input line. .sp Otherwise, \fI\fP is a list of identifiers (or identifier pairs) to be specially handled, each delimited by either a comma or by white space (in which case the list should be quoted to keep the entire list as one command line argument). .sp Multiple \fB\-I\fP options may be supplied. To clear the list of ignore identifiers, supply a single dash (\(aq\fB\-\fP\(aq) for \fI\fP\&. .sp This feature is useful when preprocessor macros are used in such a way that they cause syntactic confusion due to their presence. Indeed, this is the best way of working around a number of problems caused by the presence of syntax\-busting macros in source files (see \(dq\fI\%CAVEATS\fP\(dq). Some examples will illustrate this point. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C int foo ARGDECL4(void *, ptr, long int, nbytes) .ft P .fi .UNINDENT .UNINDENT .sp In the above example, the macro \fBARGDECL4\fP would be mistakenly interpreted to be the name of the function instead of the correct name of \fBfoo\fP\&. Specifying \(dq\fB\-I ARGDECL4\fP\(dq results in the correct behavior. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C /* creates an RCS version string in module */ MODULE_VERSION(\(dq$Revision$\(dq) .ft P .fi .UNINDENT .UNINDENT .sp In the above example the macro invocation looks too much like a function definition because it is not followed by a semicolon (indeed, it could even be followed by a global variable definition that would look much like a K&R style function parameter declaration). In fact, this seeming function definition could possibly even cause the rest of the file to be skipped over while trying to complete the definition. Specifying \(dq\fB\-I MODULE_VERSION+\fP\(dq would avoid such a problem. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CLASS Example { // your content here }; .ft P .fi .UNINDENT .UNINDENT .sp The example above uses \fBCLASS\fP as a preprocessor macro which expands to something different for each platform. For instance \fBCLASS\fP may be defined as \fBclass __declspec(dllexport)\fP on Win32 platforms and simply \fBclass\fP on UNIX. Normally, the absence of the C++ keyword \fBclass\fP would cause the source file to be incorrectly parsed. Correct behavior can be restored by specifying \(dq\fB\-I CLASS=class\fP\(dq. .TP .B \fB\-\-param\-.=\fP Set a \fI\fP specific parameter, a parameter specific to the \fI\fP\&. .sp Available parameters can be listed with \fB\-\-list\-params\fP\&. .UNINDENT .SS Listing Options .INDENT 0.0 .TP .B \fB\-\-list\-aliases[=(|all)]\fP Lists the aliases for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. The aliases are used when heuristically testing a language parser for a source file. .TP .B \fB\-\-list\-excludes\fP Lists the current exclusion patterns used to exclude files. .TP .B \fB\-\-list\-extras[=(|NONE|all)]\fP Lists the extras recognized for either the specified \fI\fP or \fBall\fP languages. If \fBNONE\fP is specified, it lists only extras common in all languages. See \(dq\fI\%Extras\fP\(dq subsection to know what are extras. \fBall\fP is used as default value if the option argument is omitted. .sp An extra can be enabled or disabled with \fB\-\-extras=\fP for common extras in all languages, or \fB\-\-extras\-=\fP for the specified language. These option takes one\-letter flag or long\-name flag as a parameter for specifying an extra. .sp The meaning of columns in output are as follows: .INDENT 7.0 .TP .B LETTER One\-letter flag. \(aq\fB\-\fP\(aq means the extra does not have one\-letter flag. .TP .B NAME Long\-name flag. The long\-name is used in \fBextras\fP field. .TP .B ENABLED Whether the extra is enabled or not. It takes \fByes\fP or \fBno\fP\&. .TP .B LANGUAGE The name of language if the extra is owned by a parser. \fBNONE\fP means the extra is common in parsers. .TP .B DESCRIPTION Human readable description for the extra. .UNINDENT .TP .B \fB\-\-list\-features\fP Lists the compiled features. .TP .B \fB\-\-list\-fields[=(|NONE|all)]\fP Lists the fields recognized for either the specified \fI\fP or \fBall\fP languages. If \fBNONE\fP is specified, it lists only fields common in all languages. See \(dq\fI\%Extension fields\fP\(dq subsection to know what are fields. \fBall\fP is used as default value if the option argument is omitted. .sp The meaning of columns are as follows: .INDENT 7.0 .TP .B LETTER One\-letter flag. \(aq\fB\-\fP\(aq means the field does not have one\-letter flag. .TP .B NAME Long\-name of field. .TP .B ENABLED Whether the field is enabled or not. It takes \fByes\fP or \fBno\fP\&. .TP .B LANGUAGE The name of language if the field is owned by a parser. \fBNONE\fP means that the field is a language\-independent field which is common in all languages. .TP .B JSTYPE JSON type used in printing the value of field when \fB\-\-output\-format=json\fP is specified. See ctags\-client\-tools(7). .TP .B FIXED Whether this field can be disabled or not in tags output. .sp Some fields are printed always in tags output. They have \fByes\fP as the value for this column. .sp Unlike the tag output mode, JSON output mode allows disabling any fields. .TP .B OP How this field can be accessed from optscript code. This field is for Universal Ctags developers. .TP .B DESCRIPTION Human readable description for the field. .UNINDENT .TP .B \fB\-\-list\-kinds[=(|all)]\fP Subset of \fB\-\-list\-kinds\-full\fP\&. This option is kept for backward\-compatibility with Exuberant Ctags. .sp This option prints only LETTER, DESCRIPTION, and ENABLED fields of \fB\-\-list\-kinds\-full\fP output. However, the presentation of ENABLED column is different from that of \fB\-\-list\-kinds\-full\fP option; \fB[off]\fP follows after description if the kind is disabled, and nothing follows if enabled. The most of all kinds are enabled by default. .sp The critical weakness of this option is that this option does not print the name of kind. Universal Ctags introduces \fB\-\-list\-kinds\-full\fP because it considers that names are important. .sp This option does not work with \fB\-\-machinable\fP nor \fB\-\-with\-list\-header\fP\&. .TP .B \fB\-\-list\-kinds\-full[=(|all)]\fP Lists the tag kinds recognized for either the specified \fI\fP or \fBall\fP languages, and then exits. See \(dq\fI\%Kinds\fP\(dq subsection to learn what kinds are. \fBall\fP is used as default value if the option argument is omitted. .sp Each kind of tag recorded in the tag file is represented by a one\-letter flag, or a long\-name flag. They are also used to filter the tags placed into the output through use of the \fB\-\-kinds\-\fP option. .sp The meaning of columns are as follows: .INDENT 7.0 .TP .B LANGUAGE The name of language having the kind. .TP .B LETTER One\-letter flag. This must be unique in a language. .TP .B NAME The long\-name flag of the kind. This can be used as the alternative to the one\-letter flag described above. If enabling \fBK\fP field with \fB\-\-fields=+K\fP, ctags uses long\-names instead of one\-letters in tags output. To enable/disable a kind with \fB\-\-kinds\-\fP option, long\-name surrounded by braces instead of one\-letter. See \(dq\fI\%Letters and names\fP\(dq for details. This must be unique in a language. .TP .B ENABLED Whether the kind is enabled or not. It takes \fByes\fP or \fBno\fP\&. .TP .B REFONLY Whether the kind is specialized for reference tagging or not. If the column is \fByes\fP, the kind is for reference tagging, and it is never used for definition tagging. See also \(dq\fI\%TAG ENTRIES\fP\(dq. .TP .B NROLES The number of roles this kind has. See also \(dq\fI\%Roles\fP\(dq. .TP .B MASTER The master parser controlling enablement of the kind. A kind belongs to a language (owner) in Universal Ctags; enabling and disabling a kind in a language has no effect on a kind in another language even if both kinds has the same one\-letter flag and/or the same long\-name flag. In other words, the namespace of kinds are separated by language. .sp However, Exuberant Ctags does not separate the kinds of C and C++. Enabling/disabling kindX in C language enables/disables a kind in C++ language having the same long\-name flag with kindX. To emulate this behavior in Universal Ctags, a concept named \fImaster parser\fP is introduced. Enabling/disabling some kinds are synchronized under the control of a master language. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-kinds\-C=+\(aq{local}\(aq \-\-list\-kinds\-full \e | grep \-E \(aq^(#|C\e+\e+ .* local)\(aq #LANGUAGE LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION C++ l local yes no 0 C local variables $ ctags \-\-kinds\-C=\-\(aq{local}\(aq \-\-list\-kinds\-full \e | grep \-E \(aq^(#|C\e+\e+ .* local)\(aq #LANGUAGE LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION C++ l local no no 0 C local variables .ft P .fi .UNINDENT .UNINDENT .sp You see \fBENABLED\fP field of \fBlocal\fP kind of C++ language is changed Though \fBlocal\fP kind of C language is enabled/disabled. If you swap the languages, you see the same result. .\" TODO: need a reference to "master parser" . .TP .B DESCRIPTION Human readable description for the kind. .UNINDENT .TP .B \fB\-\-list\-languages\fP Lists the names of the languages understood by ctags, and then exits. These language names are case insensitive and may be used in many other options like \fB\-\-language\-force\fP, \fB\-\-languages\fP, \fB\-\-kinds\-\fP, \fB\-\-regex\-\fP, and so on. .sp Each language listed is disabled if followed by \fB[disabled]\fP\&. To use the parser for such a language, specify the language as an argument of \fB\-\-languages=+\fP option. .sp \fB\-\-machinable\fP and \fB\-\-with\-list\-header\fP options are ignored if they are specified with this option. .TP .B \fB\-\-list\-map\-extensions[=(|all)]\fP Lists the file extensions which associate a file name with a language for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. .TP .B \fB\-\-list\-map\-patterns[=(|all)]\fP Lists the file name patterns which associate a file name with a language for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. .TP .B \fB\-\-list\-maps[=(|all)]\fP Lists file name patterns and the file extensions which associate a file name with a language for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. .sp To list the file extensions or file name patterns individually, use \fB\-\-list\-map\-extensions\fP or \fB\-\-list\-map\-patterns\fP option. See the \fB\-\-langmap\fP option, and \(dq\fI\%Determining file language\fP\(dq, above. .sp This option does not work with \fB\-\-machinable\fP nor \fB\-\-with\-list\-header\fP\&. .TP .B \fB\-\-list\-mline\-regex\-flags\fP Output list of flags which can be used in a multiline regex parser definition. See ctags\-optlib(7). .TP .B \fB\-\-list\-params[=(|all)]\fP Lists the parameters for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. .TP .B \fB\-\-list\-pseudo\-tags\fP Output list of pseudo\-tags. .TP .B \fB\-\-list\-regex\-flags\fP Lists the flags that can be used in \fB\-\-regex\-\fP option. See ctags\-optlib(7). .TP .B \fB\-\-list\-roles[=(|all)[.(|*)]]\fP List the roles for either the specified \fI\fP or \fBall\fP languages. \fBall\fP is used as default value if the option argument is omitted. .sp If the parameter \fI\fP is given after the parameter \fI\fP or \fBall\fP with concatenating with \(aq\fB\&.\fP\(aq, list only roles defined in the kinds. Both one\-letter flags and long name flags surrounded by braces are acceptable as the parameter \fI\fP\&. .sp The meaning of columns are as follows: .INDENT 7.0 .TP .B LANGUAGE The name of language having the role. .TP .B KIND(L/N) The one\-letter flag and the long\-name flag of kind having the role. .TP .B NAME The long\-name flag of the role. .TP .B ENABLED Whether the kind is enabled or not. It takes \fByes\fP or \fBno\fP\&. .TP .B DESCRIPTION Human readable description for the role. .UNINDENT .TP .B \fB\-\-list\-subparsers[=(|all)]\fP Lists the subparsers for a base language for either the specified \fI\fP or \fBall\fP languages, and then exits. \fBall\fP is used as default value if the option argument is omitted. .TP .B \fB\-\-machinable[=(yes|no)]\fP Use tab character as separators for \fB\-\-list\-\fP option output. It may be suitable for scripting. See \(dq\fI\%List options\fP\(dq for considered use cases. Disabled by default. .TP .B \fB\-\-with\-list\-header[=(yes|no)]\fP Print headers describing columns in \fB\-\-list\-\fP option output. See also \(dq\fI\%List options\fP\(dq. .UNINDENT .SS Miscellaneous Options .INDENT 0.0 .TP .B \fB\-\-help\fP Prints to standard output a detailed usage description, and then exits. .TP .B \fB\-?\fP Equivalent to \fB\-\-help\fP\&. .TP .B \fB\-\-help\-full\fP Prints to standard output a detailed usage description including experimental features, and then exits. Visit \fI\%https://docs.ctags.io/\fP for information about the latest exciting experimental features. .TP .B \fB\-\-license\fP Prints a summary of the software license to standard output, and then exits. .TP .B \fB\-\-print\-language\fP Just prints the language parsers for specified source files, and then exits. .TP .B \fB\-\-quiet[=(yes|no)]\fP Write fewer messages (default is \fBno\fP). .TP .B \fB\-\-totals[=(yes|no|extra)]\fP Prints statistics about the source files read and the tag file written during the current invocation of ctags. This option is \fBno\fP by default. .sp The \fBextra\fP value prints parser specific statistics for parsers gathering such information. .TP .B \fB\-\-verbose[=(yes|no)]\fP Enable verbose mode. This prints out information on option processing and a brief message describing what action is being taken for each file considered by ctags. Normally, ctags does not read command line arguments until after options are read from the configuration files (see \(dq\fI\%FILES\fP\(dq, below). However, if this option is the first argument on the command line, it will take effect before any options are read from these sources. The default is \fBno\fP\&. .TP .B \fB\-V\fP Equivalent to \fB\-\-verbose\fP\&. .TP .B \fB\-\-version[=|NONE]\fP Prints a version identifier for ctags to standard output, and then exits. This is guaranteed to always contain the string \(dqUniversal Ctags\(dq. See also the description for \fBTAG_PROGRAM_VERSION\fP and \fBTAG_OUTPUT_VERSION\fP in ctags\-client\-tools(7). .sp If \fBNONE\fP is given, prints the version identifier in a simplified way. .sp If \fI\fP is given, print the version identifier for the parser for \fI\fP\&. See also the description for \fBTAG_PARSER_VERSION\fP in ctags\-client\-tools(7). .UNINDENT .SS Obsoleted Options .sp These options are kept for backward\-compatibility with Exuberant Ctags. .INDENT 0.0 .TP .B \fB\-w\fP This option is silently ignored for backward\-compatibility with the ctags of SVR4 Unix. .TP .B \fB\-\-file\-scope[=(yes|no)]\fP This options is removed. Use \fB\-\-extras=[+|\-]F\fP or \fB\-\-extras=[+|\-]{fileScope}\fP instead. .TP .B \fB\-\-extra=[+|\-][|*]\fP Equivalent to \fB\-\-extras=[+|\-][|*]\fP, which was introduced to make the option naming convention align to the other options like \fB\-\-kinds\-=\fP and \fB\-\-fields=\fP\&. .TP .B \fB\-\-\-kinds=[+|\-](|*)\fP This option is obsolete. Use \fB\-\-kinds\-=...\fP instead. .UNINDENT .SH OPERATIONAL DETAILS .sp As ctags considers each source file name in turn, it tries to determine the language of the file by applying tests described in \(dq\fI\%Determining file language\fP\(dq. .sp If a language was identified, the file is opened and then the appropriate language parser is called to operate on the currently open file. The parser parses through the file and adds an entry to the tag file for each language object it is written to handle. See \(dq\fI\%TAG FILE FORMAT\fP\(dq, below, for details on these entries. .SS Notes for C/C++ Parser .\" TODO: move the following description to parser-cxx.rst. . .sp This implementation of ctags imposes no formatting requirements on C code as do legacy implementations. Older implementations of ctags tended to rely upon certain formatting assumptions in order to help it resolve coding dilemmas caused by preprocessor conditionals. .sp In general, ctags tries to be smart about conditional preprocessor directives. If a preprocessor conditional is encountered within a statement which defines a tag, ctags follows only the first branch of that conditional (except in the special case of \fB#if 0\fP, in which case it follows only the last branch). The reason for this is that failing to pursue only one branch can result in ambiguous syntax, as in the following example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C #ifdef TWO_ALTERNATIVES struct { #else union { #endif short a; long b; } .ft P .fi .UNINDENT .UNINDENT .sp Both branches cannot be followed, or braces become unbalanced and ctags would be unable to make sense of the syntax. .sp If the application of this heuristic fails to properly parse a file, generally due to complicated and inconsistent pairing within the conditionals, ctags will retry the file using a different heuristic which does not selectively follow conditional preprocessor branches, but instead falls back to relying upon a closing brace (\(aq\fB}\fP\(aq) in column 1 as indicating the end of a block once any brace imbalance results from following a \fB#if\fP conditional branch. .sp ctags will also try to specially handle arguments lists enclosed in double sets of parentheses in order to accept the following conditional construct: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C extern void foo __ARGS((int one, char two)); .ft P .fi .UNINDENT .UNINDENT .sp Any name immediately preceding the \(aq\fB((\fP\(aq will be automatically ignored and the previous name will be used. .sp C++ operator definitions are specially handled. In order for consistency with all types of operators (overloaded and conversion), the operator name in the tag file will always be preceded by the string \(dqoperator \(dq (i.e. even if the actual operator definition was written as \(dqoperator<<\(dq). .sp After creating or appending to the tag file, it is sorted by the tag name, removing identical tag lines. .SS Determining file language .SS File name mapping .sp Unless the \fB\-\-language\-force\fP option is specified, the language of each source file is automatically selected based upon a \fImapping\fP of file names to languages. The mappings in effect for each language may be displayed using the \fB\-\-list\-maps\fP option and may be changed using the \fB\-\-langmap\fP or \fB\-\-map\-\fP options. .sp If the name of a file is not mapped to a language, ctags tries to heuristically guess the language for the file by inspecting its content. .sp All files that have no file name mapping and no guessed parser are ignored. This permits running ctags on all files in either a single directory (e.g. \(dq\fBctags *\fP\(dq), or on all files in an entire source directory tree (e.g. \(dq\fBctags \-R\fP\(dq), since only those files whose names are mapped to languages will be scanned. .sp An extension may be mapped to multiple parsers. For example, \fB\&.h\fP are mapped to C++, C and ObjectiveC. These mappings can cause issues. ctags tries to select the proper parser for the source file by applying heuristics to its content, however it is not perfect. In case of issues one can use \fB\-\-language\-force=\fP, \fB\-\-langmap=[,[...]]\fP, or the \fB\-\-map\-=[+|\-]|\fP options. (Some of the heuristics are applied whether \fB\-\-guess\-language\-eagerly\fP is given or not.) .\" TODO: all heuristics??? To be confirmed. . .SS Heuristically guessing .sp If ctags cannot select a parser from the mapping of file names, various heuristic tests are conducted to determine the language: .INDENT 0.0 .TP .B template file name testing If the file name has an \fB\&.in\fP extension, ctags applies the mapping to the file name without the extension. For example, \fBconfig.h\fP is tested for a file named \fBconfig.h.in\fP\&. .TP .B \(dqinterpreter\(dq testing The first line of the file is checked to see if the file is a \fB#!\fP script for a recognized language. ctags looks for a parser having the same name. .sp If ctags finds no such parser, ctags looks for the name in alias lists. For example, consider if the first line is \fB#!/bin/sh\fP\&. Though ctags has a \(dqshell\(dq parser, it doesn\(aqt have a \(dqsh\(dq parser. However, \fBsh\fP is listed as an alias for \fBshell\fP, therefore ctags selects the \(dqshell\(dq parser for the file. .sp An exception is \fBenv\fP\&. If \fBenv\fP is specified (for example \(dq\fB#!/usr/bin/env python\fP\(dq), ctags reads more lines to find real interpreter specification. .sp To display the list of aliases, use \fB\-\-list\-aliases\fP option. To add an item to the list or to remove an item from the list, use the \fB\-\-alias\-=+\fP or \fB\-\-alias\-=\-\fP option respectively. .TP .B \(dqzsh autoload tag\(dq testing If the first line starts with \fB#compdef\fP or \fB#autoload\fP, ctags regards the line as \(dqzsh\(dq. .TP .B \(dqemacs mode at the first line\(dq testing The Emacs editor has multiple editing modes specialized for programming languages. Emacs can recognize a marker called modeline in a file and utilize the marker for the mode selection. This heuristic test does the same as what Emacs does. .sp ctags treats \fBMODE\fP as a name of interpreter and applies the same rule of \(dqinterpreter\(dq testing if the first line has one of the following patterns: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C \-*\- mode: MODE \-*\- .ft P .fi .UNINDENT .UNINDENT .sp or .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C \-*\- MODE \-*\- .ft P .fi .UNINDENT .UNINDENT .TP .B \(dqemacs mode at the EOF\(dq testing Emacs editor recognizes another marker at the end of file as a mode specifier. This heuristic test does the same as what Emacs does. .sp ctags treats \fBMODE\fP as a name of an interpreter and applies the same rule of \(dqinterpreter\(dq heuristic testing, if the lines at the tail of the file have the following pattern: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C Local Variables: \&... mode: MODE \&... End: .ft P .fi .UNINDENT .UNINDENT .sp 3000 characters are sought from the end of file to find the pattern. .TP .B \(dqvim modeline\(dq testing Like the modeline of the Emacs editor, Vim editor has the same concept. ctags treats \fBTYPE\fP as a name of interpreter and applies the same rule of \(dqinterpreter\(dq heuristic testing if the first or last 5 lines of the file have one of the following patterns: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C filetype=TYPE .ft P .fi .UNINDENT .UNINDENT .sp or .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C ft=TYPE .ft P .fi .UNINDENT .UNINDENT .TP .B \(dqPHP marker\(dq testing If the first line is started with \fB;\(dq .ft P .fi .UNINDENT .UNINDENT .sp The fields and separators of these lines are specified as follows: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 \fB\fP: tag name .IP 2. 3 \fB\fP: single tab character .IP 3. 3 \fB\fP: name of the file in which the object associated with the tag is located .IP 4. 3 \fB\fP: single tab character .IP 5. 3 \fB\fP: EX command used to locate the tag within the file; generally a search pattern (either \fB/pattern/\fP or \fB?pattern?\fP) or line number (see \fB\-\-excmd=\fP option). .IP 6. 3 \fB;\(dq\fP: a set of extension fields. See \(dq\fI\%Extension fields\fP\(dq for more details. .sp Tag file format 2 (see \fB\-\-format\fP) extends the EX command to include the extension fields embedded in an EX comment immediately appended to the EX command, which leaves it backward\-compatible with original \fBvi(1)\fP implementations. .UNINDENT .UNINDENT .UNINDENT .sp A few special tags, called \fIpseudo tags\fP, are written into the tag file for internal purposes. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C !_TAG_FILE_FORMAT 2 /extended format; \-\-format=1 will not append ;\(dq to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ \&... .ft P .fi .UNINDENT .UNINDENT .sp \fB\-\-pseudo\-tags=[+|\-](|*)\fP option enables or disables emitting pseudo\-tags. .sp See the output of \(dq\fBctags \-\-list\-pseudo\-tags\fP\(dq for the list of the kinds. See also tags(5) and ctags\-client\-tools(7) for more details of the pseudo tags. .sp These tags are composed in such a way that they always sort to the top of the file. Therefore, the first two characters of these tags are used a magic number to detect a tag file for purposes of determining whether a valid tag file is being overwritten rather than a source file. .sp Note that the name of each source file will be recorded in the tag file exactly as it appears on the command line. Therefore, if the path you specified on the command line was relative to the current directory, then it will be recorded in that same manner in the tag file. See, however, the \fB\-\-tag\-relative=(yes|no|always|never)\fP option for how this behavior can be modified. .SH TAG ENTRIES .sp A tag is an index for a language object. The concept of a tag and related items in Exuberant Ctags are refined and extended in Universal Ctags. .sp A tag is categorized into \fIdefinition tags\fP or \fIreference tags\fP\&. In general, Exuberant Ctags only tags \fIdefinitions\fP of language objects: places where newly named language objects \fIare introduced\fP\&. Universal Ctags, on the other hand, can also tag \fIreferences\fP of language objects: places where named language objects \fIare used\fP\&. However, support for generating reference tags is new and limited to specific areas of specific languages in the current version. .SS Extension fields .sp A tag can record various information, called \fIextension fields\fP\&. .sp Extension fields are tab\-separated key\-value pairs appended to the end of the EX command as a comment, as described above. These key value pairs appear in the general form \fBkey:value\fP\&. .sp In addition, information on the scope of the tag definition may be available, with the key portion equal to some language\-dependent construct name and its value the name declared for that construct in the program. This scope entry indicates the scope in which the tag was found. For example, a tag generated for a C structure member would have a scope looking like \fBstruct:myStruct\fP\&. .sp \fB\-\-fields=[+|\-][|*]\fP and \fB\-\-fields\-(|all)=[+|\-][|*]\fP options specifies which available extension fields are to be included in the tag entries. .sp See the output of \(dq\fBctags \-\-list\-fields\fP\(dq for the list of extension fields. The essential fields are \fBname\fP, \fBinput\fP, \fBpattern\fP, and \fBline\fP\&. The meaning of major fields is as follows (long\-name flag/one\-letter flag): .INDENT 0.0 .TP .B \fBaccess\fP/\fBa\fP Indicates the visibility of this class member, where value is specific to the language. .TP .B \fBend\fP/\fBe\fP Indicates the line number of the end lines of the language object. .TP .B \fBextras\fP/\fBE\fP Extra tag type information. See \(dq\fI\%Extras\fP\(dq for details. .TP .B \fBfile\fP/\fBf\fP Indicates that the tag has file\-limited visibility. This key has no corresponding value. Enabled by default. .TP .B \fBimplementation\fP/\fBm\fP When present, this indicates a limited implementation (abstract vs. concrete) of a routine or class, where value is specific to the language (\fBvirtual\fP or \fBpure virtual\fP for C++; \fBabstract\fP for Java). .TP .B \fBinherits\fP/\fBi\fP When present, value is a comma\-separated list of classes from which this class is derived (i.e. inherits from). .TP .B \fBinput\fP/\fBF\fP The name of source file where \fBname\fP is defined or referenced. .TP .B \fBk\fP \fI\%Kind\fP of tag as one\-letter. Enabled by default. This field has no long\-name. See also \fBkind\fP/\fBz\fP flag. .TP .B \fBK\fP \fI\%Kind\fP of tag as long\-name. This field has no long\-name. See also \fBkind\fP/\fBz\fP flag. .TP .B \fBkind\fP/\fBz\fP Include the \fBkind:\fP key in \fI\%kind field\fP\&. See also \fBk\fP and \fBK\fP flags. .TP .B \fBlanguage\fP/\fBl\fP Language of source file containing tag .TP .B \fBline\fP/\fBn\fP The line number where \fBname\fP is defined or referenced in \fBinput\fP\&. .TP .B \fBname\fP/\fBN\fP The name of language objects. .TP .B \fBnth\fP/\fBo\fP The order in the parent scope. (i.e. 4th parameter in the function). .TP .B \fBpattern\fP/\fBP\fP Can be used to search the \fBname\fP in \fBinput\fP .TP .B \fBroles\fP/\fBr\fP Roles assigned to the tag. See \(dq\fI\%Roles\fP\(dq for more details. .TP .B \fBs\fP Scope of tag definition. Enabled by default. This field has no long\-name. See also \fBscope\fP/\fBZ\fP flag. .TP .B \fBscope\fP/\fBZ\fP Prepend the \fBscope:\fP key to scope (\fBs\fP) field. See also \fBs\fP flag. .TP .B \fBscopeKind\fP/\fBp\fP Kind of scope as long\-name .TP .B \fBsignature\fP/\fBS\fP When present, value is a language\-dependent representation of the signature of a routine (e.g. prototype or parameter list). A routine signature in its complete form specifies the return type of a routine and its formal argument list. This extension field is presently supported only for C\-based languages and does not include the return type. .TP .B \fBtyperef\fP/\fBt\fP Type and name of a variable, typedef, or return type of callable like function as \fBtyperef:\fP field. Enabled by default. .UNINDENT .SS Kinds .sp \fBkind\fP is a field which represents the \fIkind\fP of language object specified by a tag. Kinds used and defined are very different between parsers. For example, C language defines \fBmacro\fP, \fBfunction\fP, \fBvariable\fP, \fBtypedef\fP, etc. .sp \fB\-\-kinds\-(|all)=[+|\-](|*)\fP option specifies a list of language\-specific kinds of tags (or kinds) to include in the output file for a particular language. .sp See the output of \(dq\fBctags \-\-list\-kinds\-full\fP\(dq for the complete list of the kinds. .sp Its value is either one of the corresponding one\-letter flags or a long\-name flag. It is permitted (and is, in fact, the default) for the key portion of this field to be omitted. The optional behaviors are controlled with the \fB\-\-fields\fP option as follows. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-o \- kinds.c foo kinds.c /^int foo() {$/;\(dq f typeref:typename:int $ ctags \-\-fields=+k \-o \- kinds.c foo kinds.c /^int foo() {$/;\(dq f typeref:typename:int $ ctags \-\-fields=+K \-o \- kinds.c foo kinds.c /^int foo() {$/;\(dq function typeref:typename:int $ ctags \-\-fields=+z \-o \- kinds.c foo kinds.c /^int foo() {$/;\(dq kind:f typeref:typename:int $ ctags \-\-fields=+zK \-o \- kinds.c foo kinds.c /^int foo() {$/;\(dq kind:function typeref:typename:int .ft P .fi .UNINDENT .UNINDENT .SS Roles .sp \fIRole\fP is a newly introduced concept in Universal Ctags. Role is a concept associated with reference tags, and is not implemented widely yet. .sp As described previously in \(dq\fI\%Kinds\fP\(dq, the \fBkind\fP field represents the type of language object specified with a tag, such as a function vs. a variable. Specific kinds are defined for reference tags, such as the C++ kind \fBheader\fP for header file, or Java kind \fBpackage\fP for package statements. For such reference kinds, a \fBroles\fP field can be added to distinguish the role of the reference kind. In other words, the \fBkind\fP field identifies the \fIwhat\fP of the language object, whereas the \fBroles\fP field identifies the \fIhow\fP of a referenced language object. Roles are only used with specific kinds. .sp For a definition tag, this field takes \fBdef\fP as a value. .sp For example, \fBBaz\fP is tagged as a reference tag with kind \fBpackage\fP and with role \fBimported\fP with the following code. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C package Bar; import Baz; class Foo { // ... } .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-fields=+KEr \-uo \- roles.java Bar roles.java /^package Bar;$/;\(dq package roles:def Foo roles.java /^class Foo {$/;\(dq class roles:def $ ctags \-\-fields=+EKr \-\-extras=+r \-uo \- roles.java Bar roles.java /^package Bar;$/;\(dq package roles:def Baz roles.java /^import Baz;$/;\(dq package roles:imported extras:reference Foo roles.java /^class Foo {$/;\(dq class roles:def .ft P .fi .UNINDENT .UNINDENT .sp \fB\-\-roles\-(|all).(|all)=[+|\-][|*]\fP option specifies a list of kind\-specific roles of tags to include in the output file for a particular language. .sp Inquire the output of \(dq\fBctags \-\-list\-roles\fP\(dq for the list of roles. .SS Extras .sp Generally, ctags tags only language objects appearing in source files, as is. In other words, a value for a \fBname:\fP field should be found on the source file associated with the \fBname:\fP\&. An \fBextra\fP type tag (\fIextra\fP) is for tagging a language object with a processed name, or for tagging something not associated with a language object. A typical extra tag is \fBqualified\fP, which tags a language object with a class\-qualified or scope\-qualified name. .sp \fB\-\-extras\-(|all)=[+|\-][|*]\fP option specifies whether to include extra tag entries for certain kinds of information. .sp Inquire the output of \fBctags \-\-list\-extras\fP for the list of extras. The meaning of major extras is as follows (long\-name flag/one\-letter flag): .INDENT 0.0 .TP .B \fBanonymous\fP/none Include an entry for the language object that has no name like lambda function. This extra has no one\-letter flag and is enabled by default. .sp The extra tag is useful as a placeholder to fill scope fields for language objects defined in a language object with no name. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C struct { double x, y; } p = { .x = 0.0, .y = 0.0 }; .ft P .fi .UNINDENT .UNINDENT .sp \(aq\fBx\fP\(aq and \(aq\fBy\fP\(aq are the members of a structure. When filling the scope fields for them, ctags has trouble because the struct where \(aq\fBx\fP\(aq and \(aq\fBy\fP\(aq belong to has no name. For overcoming the trouble, ctags generates an anonymous extra tag for the struct and fills the scope fields with the name of the extra tag. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-fields=\-f \-uo \- input.c __anon9f26d2460108 input.c /^struct {$/;\(dq s x input.c /^ double x, y;$/;\(dq m struct:__anon9f26d2460108 y input.c /^ double x, y;$/;\(dq m struct:__anon9f26d2460108 p input.c /^} p = { .x = 0.0, .y = 0.0 };$/;\(dq v typeref:struct:__anon9f26d2460108 .ft P .fi .UNINDENT .UNINDENT .sp The above tag output has \fB__anon9f26d2460108\fP as an anonymous extra tag. The typeref field of \(aq\fBp\fP\(aq also receives the benefit of it. .TP .B \fBfileScope\fP/\fBF\fP Indicates whether tags scoped only for a single file (i.e. tags which cannot be seen outside of the file in which they are defined, such as language objects with \fBstatic\fP modifier of C language) should be included in the output. See also the \fB\-h\fP option. .sp This extra tag is enabled by default. Add \fB\-\-extras=\-F\fP option not to output tags scoped only for a single\-file. This is the replacement for \fB\-\-file\-scope\fP option of Exuberant Ctags. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C static int f() { return 0; } int g() { return 0; } .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-uo \- filescope.c f filescope.c /^static int f() {$/;\(dq f typeref:typename:int file: g filescope.c /^int g() {$/;\(dq f typeref:typename:int $ ctags \-\-extras=\-F \-uo \- filescope.c g filescope.c /^int g() {$/;\(dq f typeref:typename:int .ft P .fi .UNINDENT .UNINDENT .TP .B \fBinputFile\fP/\fBf\fP Include an entry for the base file name of every source file (e.g. \fBexample.c\fP), which addresses the first line of the file. This flag is the replacement for \fB\-\-file\-tags\fP hidden option of Exuberant Ctags. .sp If the \fBend:\fP field is enabled, the end line number of the file can be attached to the tag. (However, ctags omits the \fBend:\fP field if no newline is in the file like an empty file.) .sp By default, ctags doesn\(aqt create the \fBinputFile\fP/\fBf\fP extra tag for the source file when ctags doesn\(aqt find a parser for it. Enabling \fBUnknown\fP parser with \fB\-\-languages=+Unknown\fP forces ctags to create the extra tags for any source files. .sp The etags mode enables the \fBUnknown\fP parser implicitly. .TP .B \fBpseudo\fP/\fBp\fP Include pseudo\-tags. Enabled by default unless the tag file is written to standard output. See ctags\-client\-tools(7) about the detail of pseudo\-tags. .TP .B \fBqualified\fP/\fBq\fP Include an extra class\-qualified or namespace\-qualified tag entry for each tag which is a member of a class or a namespace. .sp This may allow easier location of a specific tags when multiple occurrences of a tag name occur in the tag file. Note, however, that this could potentially more than double the size of the tag file. .sp The actual form of the qualified tag depends upon the language from which the tag was derived (using a form that is most natural for how qualified calls are specified in the language). For C++ and Perl, it is in the form \fBclass::member\fP; for Eiffel and Java, it is in the form \fBclass.member\fP\&. .sp Note: Using backslash characters as separators forming qualified name in PHP. However, in tags output of Universal Ctags, a backslash character in a name is escaped with a backslash character. See tags(5) about the escaping. .sp The following example demonstrates the \fBqualified\fP extra tag. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C class point { double x; }; .ft P .fi .UNINDENT .UNINDENT .sp For the above source file, ctags tags \fBpoint\fP and \fBx\fP by default. If the \fBqualified\fP extra is enabled from the command line (\fB\-\-extras=+q\fP), then \fBpoint.x\fP is also tagged even though the string \(dq\fBpoint.x\fP\(dq is not in the source code. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-fields=+K \-uo \- qualified.java point qualified.java /^class point {$/;\(dq class x qualified.java /^ double x;$/;\(dq field class:point $ ctags \-\-fields=+K \-\-extras=+q \-uo \- qualified.java point qualified.java /^class point {$/;\(dq class x qualified.java /^ double x;$/;\(dq field class:point point.x qualified.java /^ double x;$/;\(dq field class:point .ft P .fi .UNINDENT .UNINDENT .TP .B \fBreference\fP/\fBr\fP Include reference tags. See \(dq\fI\%TAG ENTRIES\fP\(dq about reference tags. .sp The following example demonstrates the \fBreference\fP extra tag. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C #include #include \(dqutils.h\(dq #define X #undef X .ft P .fi .UNINDENT .UNINDENT .sp The \fBroles:system\fP or \fBroles:local\fP fields will be added depending on whether the include file name begins with \(aq\fB<\fP\(aq or not. .sp \(dq\fB#define X\fP\(dq emits a definition tag. On the other hand \(dq\fB#undef X\fP\(dq emits a reference tag. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C $ ctags \-\-fields=+EKr \-uo \- inc.c X inc.c /^#define X$/;\(dq macro file: roles:def extras:fileScope $ ctags \-\-fields=+EKr \-\-extras=+r \-uo \- inc.c stdio.h inc.c /^#include /;\(dq header roles:system extras:reference utils.h inc.c /^#include \(dqutils.h\(dq/;\(dq header roles:local extras:reference X inc.c /^#define X$/;\(dq macro file: roles:def extras:fileScope X inc.c /^#undef X$/;\(dq macro file: roles:undef extras:fileScope,reference .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS Language\-specific fields and extras .sp Exuberant Ctags has the concept of \fIfields\fP and \fIextras\fP\&. They are common between parsers of different languages. Universal Ctags extends this concept by providing language\-specific fields and extras. .\" Note: kinds are language-specific since e-ctags. roles are new to u-ctags. . .\" TODO: move the following "Hot to ..." sections to FAQ man page when available . .SH HOW TO USE WITH VI .sp \fBvi(1)\fP will, by default, expect a tag file by the name \fBtags\fP in the current directory. Once the tag file is built, the following commands exercise the tag indexing feature: .INDENT 0.0 .TP .B \fBvi \-t tag\fP Start vi and position the cursor at the file and line where \fBtag\fP is defined. .TP .B \fB:ta tag\fP Find a tag. .TP .B \fBCtrl\-]\fP Find the tag under the cursor. .TP .B \fBCtrl\-T\fP Return to previous location before jump to tag (not widely implemented). .UNINDENT .SH HOW TO USE WITH GNU EMACS .sp \fBemacs(1)\fP will, by default, expect a tag file by the name \fBTAGS\fP in the current directory. Once the tag file is built, the following commands exercise the tag indexing feature: .INDENT 0.0 .TP .B \fBM\-x visit\-tags\-table FILE \fP Select the tag file, \fBFILE\fP, to use. .TP .B \fBM\-. [TAG] \fP Find the first definition of TAG. The default tag is the identifier under the cursor. .TP .B \fBM\-*\fP Pop back to where you previously invoked \fBM\-.\fP\&. .TP .B \fBC\-u M\-.\fP Find the next definition for the last tag. .UNINDENT .sp For more commands, see the Tags topic in the Emacs info document. .SH HOW TO USE WITH NEDIT .sp NEdit version 5.1 and later can handle the new extended tag file format (see \fB\-\-format\fP). .INDENT 0.0 .IP \(bu 2 To make NEdit use the tag file, select \(dqFile\->Load Tags File\(dq. .IP \(bu 2 To jump to the definition for a tag, highlight the word, then press \fBCtrl\-D\fP\&. .UNINDENT .sp NEdit 5.1 can read multiple tag files from different directories. Setting the X resource \fBnedit.tagFile\fP to the name of a tag file instructs NEdit to automatically load that tag file at startup time. .SH CAVEATS .sp Because ctags is neither a preprocessor nor a compiler, use of preprocessor macros can fool ctags into either missing tags or improperly generating inappropriate tags. Although ctags has been designed to handle certain common cases, this is the single biggest cause of reported problems. In particular, the use of preprocessor constructs which alter the textual syntax of C can fool ctags. You can work around many such problems by using the \fB\-I\fP option. .sp Note that since ctags generates patterns for locating tags (see the \fB\-\-excmd\fP option), it is entirely possible that the wrong line may be found by your editor if there exists another source line which is identical to the line containing the tag. The following example demonstrates this condition: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C int variable; /* ... */ void foo(variable) int variable; { /* ... */ } .ft P .fi .UNINDENT .UNINDENT .sp Depending upon which editor you use and where in the code you happen to be, it is possible that the search pattern may locate the local parameter declaration before it finds the actual global variable definition, since the lines (and therefore their search patterns) are identical. .sp This can be avoided by use of the \fB\-\-excmd=n\fP option. .SH INCOMPATIBLE CHANGES .sp See ctags\-incompatibilities(7) about incompatibilities between Universal Ctags and Exuberant Ctags. .sp This section describes major incompatibilities within versions of Universal Ctags. .INDENT 0.0 .TP .B Unifying the kind Letter for \fBunknown\fP kinds Some parsers used different kind letters for \fBunknown\fP kinds. EmacsLisp used \fBu\fP\&. Go used \fBu\fP\&. Julian used \fBx\fP\&. Lisp used \fBu\fP\&. Lua used \fBX\fP\&. and Python used \fBx\fP\&. They were unified to \fBY\fP in the during development of version 5.9.x. .UNINDENT .SH BUGS .sp ctags has more options than \fBls(1)\fP\&. .sp ctags assumes the input file is written in the correct grammar. Otherwise output of ctags is undefined. In other words it has garbage in, garbage out (GIGO) feature. .\" TODO: move the following paragraph to parser-cxx.rst. . .sp When parsing a C++ member function definition (e.g. \fBclassName::function\fP), ctags cannot determine whether the scope specifier is a class name or a namespace specifier and always lists it as a class name in the scope portion of the extension fields. Also, if a C++ function is defined outside of the class declaration (the usual case), the access specification (i.e. public, protected, or private) and implementation information (e.g. virtual, pure virtual) contained in the function declaration are not known when the tag is generated for the function definition. It will, however be available for prototypes (e.g. \fB\-\-kinds\-c++=+p\fP). .sp No qualified tags are generated for language objects inherited into a class. .SH ENVIRONMENT VARIABLES .INDENT 0.0 .TP .B \fBTMPDIR\fP On Unix\-like hosts where \fBmkstemp(3)\fP is available, the value of this variable specifies the directory in which to place temporary files. This can be useful if the size of a temporary file becomes too large to fit on the partition holding the default temporary directory defined at compilation time. .sp ctags creates temporary files only if either (1) an emacs\-style tag file is being generated, (2) the tag file is being sent to standard output, or (3) the program was compiled to use an internal sort algorithm to sort the tag files instead of the \fBsort(1)\fP utility of the operating system. If the \fBsort(1)\fP utility of the operating system is being used, it will generally observe this variable also. .sp Note that if ctags is setuid, the value of \fBTMPDIR\fP will be ignored. .UNINDENT .SH FILES .SS Output files .INDENT 0.0 .TP .B \fBtags\fP The default tag file created by ctags. .TP .B \fBTAGS\fP The default tag file created by etags. .UNINDENT .SS Preloading option files .sp \fB$XDG_CONFIG_HOME/ctags/*.ctags\fP, or \fB$HOME/.config/ctags/*.ctags\fP if \fB$XDG_CONFIG_HOME\fP is not defined (on other than MS Windows) .sp \fB$HOME/.ctags.d/*.ctags\fP .sp \fB$HOMEDRIVE$HOMEPATH/ctags.d/*.ctags\fP (on MS Windows only) .sp \fB\&.ctags.d/*.ctags\fP .sp \fBctags.d/*.ctags\fP .INDENT 0.0 .INDENT 3.5 If any of these configuration files exist, each will be expected to contain a set of default options which are read in the order listed when ctags starts, but before any command line options are read. This makes it possible to set up personal or project\-level defaults. .sp It is possible to compile ctags to read an additional configuration file before any of those shown above, which will be indicated if the output produced by the \fB\-\-version\fP option lists the \fBcustom\-conf\fP feature. .sp Options appearing on the command line will override options specified in these files. Only options will be read from these files. .sp Note that the option files are read in line\-oriented mode in which spaces are significant (since shell quoting is not possible) but spaces at the beginning of a line are ignored. Each line of the file is read as one command line parameter (as if it were quoted with single quotes). Therefore, use new lines to indicate separate command\-line arguments. .sp A line starting with \(aq\fB#\fP\(aq is treated as a comment. .sp \fB*.ctags\fP files in a directory are loaded in alphabetical order. .UNINDENT .UNINDENT .SS Default optlib path list .sp \fB$XDG_CONFIG_HOME/ctags\fP, or \fB$HOME/.config/ctags\fP if \fB$XDG_CONFIG_HOME\fP is not defined (on other than MS Windows) .sp \fB$HOME/.ctags.d\fP .sp \fB$HOMEDRIVE$HOMEPATH/ctags.d\fP (on MS Windows only) .INDENT 0.0 .INDENT 3.5 These directories are parts of the optlib path list by default. See \(dq\fI\%Option File Options\fP\(dq about the optlib path list. .sp If you have a set of options that you want to enable conditionally, make a directory in the path in the optlib path list, and put the options to the files having .ctags as extensions under the directory. \fB\-\-options=\fP is for enabling the options. .sp For example, consider you have some options you want to enable only when tagging the Linux kernel source tree. In that case, make \fB$HOME/.ctags.d/linux\fP directory, put the options to \fB$HOME/.ctags.d/linux/my.ctags\fP\&. If you have many options, you can split them into multiple files like \fB$HOME/.ctags.d/linux/device\-driver.ctags\fP and \fB$HOME/.ctags.d/linux/network\-stack.ctags\fP\&. Either way, you can enable the options in the .ctags file(s) under the directory by adding \fB\-\-options=linux\fP to your ctags command line. .UNINDENT .UNINDENT .SH SEE ALSO .sp See ctags\-optlib(7) for defining (or extending) a parser in a configuration file. .sp See tags(5) for the format of tag files. .sp See ctags\-incompatibilities(7) about known incompatible changes with Exuberant Ctags. .sp See ctags\-client\-tools(7) if you are interested in writing a tool for processing tags files. .sp See ctags\-lang\-python(7) about python input specific notes. .sp See readtags(1) about a client tool for binary searching a name in a sorted tags file. .sp The official Universal Ctags web site at: \fI\%https://ctags.io/\fP .sp Also \fBex(1)\fP, \fBvi(1)\fP, \fBelvis(1)\fP, or, better yet, \fBvim(1)\fP, the official editor of ctags. For more information on \fBvim(1)\fP, see the Vim web site at: \fI\%https://www.vim.org/\fP .SH AUTHOR .sp Universal Ctags project \fI\%https://ctags.io/\fP .sp Darren Hiebert <\fI\%dhiebert@users.sourceforge.net\fP> \fI\%http://DarrenHiebert.com/\fP .SH MOTIVATION .sp \(dqThink ye at all times of rendering some service to every member of the human race.\(dq .sp \(dqAll effort and exertion put forth by man from the fullness of his heart is worship, if it is prompted by the highest motives and the will to do service to humanity.\(dq .sp \-\- From the Baha\(aqi Writings .SH CREDITS .sp This version of ctags (Universal Ctags) derived from the repository, known as fishman\-ctags, started by Reza Jelveh. .sp The fishman\-ctags was derived from Exuberant Ctags. .sp Some parsers are taken from \fBtagmanager\fP of the Geany (\fI\%https://www.geany.org/\fP) project. .sp Exuberant Ctags was originally derived from and inspired by the ctags program by Steve Kirkendall <\fI\%kirkenda@cs.pdx.edu\fP> that comes with the Elvis vi clone (though virtually none of the original code remains). .sp Credit is also due Bram Moolenaar <\fI\%Bram@vim.org\fP>, the author of vim, who has devoted so much of his time and energy both to developing the editor as a service to others, and to helping the orphans of Uganda. .sp The section entitled \(dq\fI\%HOW TO USE WITH GNU EMACS\fP\(dq was shamelessly stolen from the info page for GNU etags. .\" Generated by docutils manpage writer. .