MAN page from Trustix vim-5.7-3tr.i586.rpm
CTAGS
Section: User Commands (1)
Updated: Version 3.5.1
Index
NAME
ctags - Generate tag files for source code
SYNOPSIS
- ctags [options] [file(s)]
- etags [options] [file(s)]
DESCRIPTION
The
ctags and
etags programs (hereinafter collectively referred toas
ctags, except where distinguished) generate an index (or "tag") filefor C, C++, Eiffel, Fortran, and Java language objects found in
file(s).This tag file allows these items to be quickly and easily located by a texteditor or other utility. A "tag" signifies a language object for which anindex entry is available (or, alternatively, the index entry created for thatobject).
Alternatively, ctags can generate a cross reference file which lists, inhuman readable form, information about the various source objects found in aset of language files.
Tag index files are supported by numerous editors, which allow the user tolocate the object associated with a name appearing in a source file and jumpto the file and line which defines the name. Those known about at the time ofrelease are:
- vi(1) and its many derivatives
emacs
CRiSP
FTE (Folding Text Editor)
Lemmy
NEdit
TSE (The SemWare Editor)
Zeus
Ctags is capable of generating tags for all of the following languageconstructs:
- C/C++:
- macros (names defined/undefined by #define/#undef)
enumerators (enumerated values)
function definitions, prototypes, and declarations
class, enum, struct, and union names
namespaces
typedefs
variables (definitions and declarations)
class, struct, and union members
- Eiffel:
- classes
features
local entities
- Fortran:
- block data
common blocks
entry points
functions
interfaces
labels
modules
namelists
programs
subroutines
derived types
- Java:
- classes
fields
interfaces
methods
packages
SOURCE FILES
The language of each source file is automatically selected based upon its fileextension (unless the --lang option is specified). File extensions aremapped to source file languages according to the following default mapping(unless the --langmap option is specified):
- C
- *.c
- C++
- *.C *.c++ *.cc *.cpp *.cxx *.h *.H *.hh *.hpp *.hxx *.h++
- Eiffel
- *.e
- Fortran
- *.f *.for *.ftn *.f77 *.f90 *.f95 *.F *.FOR *.FTN *.F77 *.F90 *.F95
- Java
- *.java
By default, all other files extensions are ignored. This permits runningctags on all files in either a single directory (e.g. "ctags *"), or allfiles in an entire source directory tree (e.g. "ctags -R"), since only thosefiles whose extensions are known to ctags will be scanned.
The reason that .h extensions are mapped to C++ files rather than C filesis because no information is lost and because it is common to use .hextensions in C++, where information would be lost if .h files were parsedwith C rules.
OPTIONS
Despite the wealth of available options, defaults are set so that ctagsis most commonly executed without any options (e.g. "ctags *"), which willcreate a tag file in the current directory for all known source files. Theoptions described below are provided merely to allow custom tailoring to meetspecial needs.
Note that spaces separating the single-letter options from their parametersare optional.
Note also that the boolean parameters to the long form options (thosebeginning with "--" and that take a "=yes|no" parameter) maybe omitted, in which case "=yes" is implied. (e.g. --sortis equivalent to --sort=yes). Note further that "=1" and"=on" are considered synonyms for "=yes", and that "=0"and "=off" are considered synonyms for "=no".
Some options are either ignored, or only useful, when used together withetags or, equivalently, when ctags is run with the -eoption. These options will be noted.
Most options may appear anywhere on the command line, affecting only thosefiles which follow the option. A few options, however, must appear before thefirst file name and will be noted as such.
- -a
- Equivalent to --append.
- -B
- Use backward searching patterns (e.g. ?regexp?). [Ignored with -e]
- -e
- Output a tag file for use with Emacs. If this program is executed by the nameetags, this option is enabled by default. This option must appear beforethe first file name.
- -f tagfile
- Use the name specified by tagfile for the tag file (default is "tags",or "TAGS" when using the -e option). If tagfile is specified as"-", then the tag file is written to standard output instead. Ctagswill stubbornly refuse to take orders if tagfile exists and its firstline contains something other than a valid tags line. This will save your neckif you mistakenly type "ctags -f *.c", which would otherwise overwrite yourfirst C file with the tags generated by the rest! This option must appearbefore the first file name. If this option is specified more than once, onlythe last will apply.
- -F
- Use forward searching patterns (e.g. /regexp/) (default).[Ignored with -e]
- -h list
- Specifies a list of file extensions, separated by periods, which are to beinterpreted as include, or header, files. This option affects how the scopingof tag types is interpreted (i.e. whether or not they are considered asglobally visible or visible only within the file in which they are defined).Any tag type 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 tag type appearing in an include file will be considered to havefile-limited scope. If the first character in the list is a plus sign, thenthe extensions in the list will be appended to the current list; otherwise,the list will replace the current list. See also the --file-scopeoption. The default list is ".h.H.hh.hpp.hxx.h++.inc.def".To restore the default list, specify -h default.
- -i types
- This option is similar to the --c-types option and is retained forcompatibility with earlier versions. If types begins with the '='character, it is equivalent to --c-types=types. Otherwise, it isequivalent to --c-types=+types. In addition, for backwardcompatibility, the following two additional modifiers are accepted:
- F
- An alternative for the --file-tags option.
- S
- An alternative for the --file-scope option.
- -I tokenlist
- Specifies a list of tokens which are to be specially handled while parsing Cand C++ source files. This option is specifically provided to handle specialcases arising through the use of preprocessor macros. When the tokens listedare simple tokens, these tokens will be ignored during parsing of the sourcefiles. If a token is suffixed with a '+' character, ctags will alsoignore any parenthesis-enclosed argument list which may immediately follow thetoken in the source files. If two tokens are separated with the '=' character,the first token is replaced by the second token for parsing purposes. The listof tokens may be supplied directly on the command line or read in from aseparate file. If the first character of tokenlist is either a '.' or apathname separator ('/' or '\'), the parameter tokenlist will beinterpreted as a filename from which to read a list of white-space delimitedtokens (use "./filename" to specify a file found in the current directory).Otherwise, tokenlist is a list of tokens (or token pairs) to bespecially handled, each delimited by a either a comma or by white space (inwhich case the list should be quoted to keep the entire list as one commandline argument). Multiple -I options may be supplied. To clear the listof ignore tokens, supply a single dash ("-") for tokenlist.
This feature is useful when preprocessor macros are used in such a way thatthey cause syntactic confusion due to their presence. Indeed, this is the bestway of working around a number of problems caused by the presence ofsyntax-busting macros in source files (see BUGS, below). Some exampleswill illustrate this point.
- int foo ARGDECL4(void *, ptr, long int, nbytes)
- In the above example, the macro "ARGDECL4" would be mistakenly interpreted tobe the name of the function instead of the correct name of "foo". Specifying-I ARGDECL4 results in the correct behavior.
- /* creates an RCS version string in module */
MODULE_VERSION("$Revision: 8.25 $")
- In the above example the macro invocation looks too much like a functiondefinition because it is not followed by a semicolon (indeed, it could even befollowed by a global variable definition that would look much like a K&R stylefunction parameter declaration). In fact, this seeming function definitioncould possibly even cause the rest of the file to be skipped over while tryingto complete the definition. Specifying -I MODULE_VERSION+ wouldavoid such a problem.
- CLASS Example {
- // your content here
};
The example above uses "CLASS" as a preprocessor macro which expands tosomething different for each platform. For instance CLASS may be defined as"class __declspec(ddlexport)" on Win32 platforms and simply "class" on UNIX.Normally, the absence of the C++ keyword "class" would cause the source fileto be incorrectly parsed. Correct behavior can be restored by specifying-I CLASS=class.
- -L file
- Read from file a list of file names for which tags should be generated.If file is specified as "-", then file names are read from standardinput. File names read using this option are processed following file namesappearing on the command line. Options all also accepted in this input. Ifthis option is specified more than once, only the last will apply. Note:file is read in line-oriented mode, where a new line is the onlydelimiter and spaces are considered significant, in order that file namescontaining spaces may be supplied; this can affect how options are parsed ifincluded in the input.
- -n
- Equivalent to --excmd=number.
- -N
- Equivalent to --excmd=pattern.
- -o tagfile
- Equivalent to -f tagfile.
- -p path
- Use path as the default directory for each supplied source file (whethersupplied on the command line or in a file specified with the -L option),unless the source file is already specified as an absolute path. The suppliedpath is merely prepended to the each non-absolute source file name(adding any necessary path separator) before attempting to open it.
- -R
- Equivalent to --recurse.
- -u
- Equivalent to --sort=no (i.e. "unsorted").
- -V
- Equivalent to --verbose.
- -x
- Print a tabular, human-readable cross reference (xref) file to standard outputinstead of generating a tag file. The information contained in the outputincludes: the tag name; the kind of tag; the line number, file name, andsource line (with extra white space condensed) of the file which defines thetag. No tag file is written and all options affecting tag file output will beignored. Example applications for this feature are generating a listing of allfunctions located in a source file (e.g. ctags -x --c-types=ffile), or generating a list of all externally visible global variableslocated in a source file (e.g. ctags -x --c-types=v--file-scope=no file). This option must appear before the firstfile name.
- --append=yes|no
- Indicates whether tags generated from the specified files should be appendedto those already present in the tag file or should replace them. This optionis off by default. This option must appear before the first file name.[Ignored with -e]
- --c-types=types
- Specifies a list of C/C++ language tag types to include in the output file.The parameter types is a group of one-letter flags designating types oftags (listed below) to either include or exclude from the output. Each letteror group of letters may be preceded by either '+' to add it to the defaultset, or '-' to exclude it. In the absence of any preceding '+' or '-' sign,only those types explicitly listed in types will be included in theoutput (i.e. overriding the default). For example, to exclude macros butinclude prototypes, use --c-types=-d+p; to include only tags forfunctions, use --c-types=f. Tags for the following languageconstructs are supported (types are enabled by default except as noted):
- c
- classes
- d
- macro definitions (and #undef names)
- e
- enumerators
- f
- function definitions
- g
- enumeration names
- m
- class, struct, or union members
- n
- namespaces
- p
- function prototypes and declarations [off]
- s
- structure names
- t
- typedefs
- u
- union names
- v
- variable definitions
- x
- extern and forward variable declarations [off]
- In addition to the above flags, the following one-letter modifiers areaccepted:
- A
- Record the access of each member into the tag file. This information isrecorded using an extension flag labeled "access".
- C
- Include an extra, class-qualified tag entry for each class member in the form"class::member". This allows locating class-qualified tags (e.g. ":tagclass::member" in vi(1)). This is disabled by default because this couldpotentially more than double the size of the tag file.
- --eiffel-types=types
- Specifies a list of Eiffel language tag types to be included in the output.See --c-types for the definition of the format of types. Tags forthe following Eiffel language constructs are supported (types are enabled bydefault except as noted):
- c
- classes
- f
- features
- l
- local entities [off]
- In addition to the above flags, the following one-letter modifiers areaccepted:
- C
- Include an extra, class-qualified tag entry for each class member in the form"class.member". This allows locating class-qualified tags (e.g. ":tagclass.member" in vi(1)). This is disabled by default because this couldpotentially more than double the size of the tag file.
- --etags-include=file
- Include a reference to file in the tag file. This option may bespecified as many times as desired. This supports Emacs' capability to use atag file which "includes" other tag files. [Used only with -e]
- --excmd=type
- Determines the type of EX command used to locate tags in the source file.[Ignored with -e]
- The valid values for type (either the entire word or the first letter isaccepted) are:
- number
- Use only line numbers in the tag file for locating tags. This has fouradvantages:
- 1.
- Significantly reduces the size of the resulting tag file.
- 2.
- Eliminates failures to find tags because the line defining the tag haschanged, causing the pattern match to fail (note that some editors, such asvim, are able to recover in many such instances).
- 3.
- Eliminates finding identical matching, but incorrect, source lines (seeBUGS, below).
- 4.
- Retains separate entries in the tag file for lines which are identical incontent. In pattern mode, duplicate entries are dropped because thesearch patterns they generate are identical, making the duplicate entriesuseless.
However, this option has one significant drawback: changes to the source filescan cause the line numbers recorded in the tag file to no longer correspondto the lines in the source file, causing jumps to some tags to miss the targetdefinition by one or more lines. Basically, this option is best used when thesource code to which it is applied is not subject to change. Selecting thisoption type causes the following options to be ignored: -BF.
- pattern
- Use only search patterns for all tags, rather than the line numbers usuallyused for macro definitions. This has the advantage of not referencing obsoleteline numbers when lines have been added or removed since the tag file wasgenerated.
- mixed
- In this mode, patterns are generally used with a few exceptions. For C, linenumbers are used for macro definition tags. This was the default formatgenerated by the original ctags and is, therefore, retained as thedefault for this option. For Fortran, line numbers are used for common blocksbecause their corresponding source lines are generally identical, makingpattern searches useless for finding all matches.
- --file-scope=yes|no
- Indicates whether tags scoped only for a single file (i.e. tags which cannotbe seen outside of the file in which they are defined, such as "static" tags)should be included in the output. See also the -h option. This option isenabled by default.
- --file-tags=yes|no
- Indicates whether tags should be generated for source file names. This optionis disabled by default.
- --filter=yes|no
- Causes ctags to behave as a filter, reading source file names fromstandard input and printing their tags to standard output on a file-by-filebasis. If --sorted is enabled, tags are sorted only within the sourcefile in which they are defined. File names are read from standard output inline-oriented input mode (see note for -L option) and only after filenames listed on the command line or from any file supplied using the -Loption. When this option is enabled, the options -f, -o,and --totals are ignored. This option is quite estoteric and is disabledby default. This option must appear before the first file name.
- --filter-terminator=string
- Specifies a string to print to standard output following the tags for eachfile name parsed when the --filter option is enabled. This may permit anapplication reading the output of ctags to determine when the output for eachfile is finished. Note that if the file name read is a directory and--recurse is enabled, this string will be printed only one once at theend of all tags found for by descending the directory. This string will alwaysbe separated from the last tag line for the file by its terminating newline.This option is quite esoteric and is empty by default. This option must appearbefore the first file name.
- --format=level
- Change the format of the output tag file. Currently the only valid values forlevel are 1 or 2. Level 1 specifies the original tag fileformat and level 2 specifies a new extended format containing extension flags(but in a manner which retains backward compatibility with originalvi(1) implementations). The default level is 2. This option must appearbefore the first file name. [Ignored with -e]
- --fortran-types=types
- Specifies a list of Fortran language tag types to be included in the output.See --c-types for the definition of the format of types. Tags forthe following Fortran language constructs are supported (types are enabledby default except as noted):
- b
- block data
- c
- common blocks
- e
- entry points
- f
- functions
- i
- interfaces
- l
- labels [off]
- m
- modules
- n
- namelists
- p
- programs
- s
- subroutines
- t
- derived types
- --help
- Prints to standard output a detailed usage description.
- --if0=yes|no
- Indicates a preference as to whether code within an "#if 0" branch of apreprocessor conditional should be examined for non-macro tags (macro tags arealways included). Because the intent of this construct is to disable code, thedefault value of this options is no. Note that this indicates apreference only and does not guarantee skipping code within an "#if 0" branch,since the fall-back algorithm used to generate tags when preprocessorconditionals are too complex follows all branches of a conditional. Thisoption is disabled by default.
- --java-types=types
- Specifies a list of Java language tag types to be included in the output.See --c-types for the definition of the format of types. Tags forthe following Java language constructs are supported (all are enabled bydefault):
- c
- classes
- f
- fields
- i
- interfaces
- m
- methods
- p
- packages
- In addition to the above flags, the following one-letter modifiers areaccepted:
- A
- Record the access of each field into the tag file. This information isrecorded using an extension flag labeled "access".
- C
- Include an extra, class-qualified tag entry for each class member in the form"class.member". This allows locating class-qualified tags (e.g. ":tagclass.member" in vi(1)). This is disabled by default because this couldpotentially more than double the size of the tag file.
- --kind-long=yes|no
- Specifies whether the identifier for the kind of the tag listed in extensionflags of the tag file is a verbose name or a single letter. See thedescription of kind in EXTENSION FLAGS, below. When enabled, thiswill increase the size of the output by an average of about 5 characters perline or, roughly, 5%. This option must appear before the first file name.
- --lang=auto|c|c++|eiffel|fortran|java
- By default, ctags automatically selects the language of a source fileaccording to its file name extension, ignoring those files whose extensionsare unrecognized by ctags. This option forces the specified language tobe used for every supplied file instead of automatically selecting thelanguage based upon its extension. The default is auto.
- --langmap=map(s)
- Changes the mapping between file extensions and source languages (seeSOURCE FILES, above). Each comma-separated map consists of thesource language name, a colon, and a list of extensions separated by periods.If the first character in a map is a plus sign, then the extensions in thatmap will be appended to the current map for that language; otherwise, the mapwill replace the current map. For example, to specify that only files withextensions of .c, .ec, and .xs are to be treated as C language files, use"--langmap=c:.c.ec.xs". To also specify that files with extensionsof .j are to be treated as Java language files, use"--langmap=c:.c.ec.xs,java:+.j". To clear the mapping for aparticular language (thus preventing generation of tags for that language),specify an empty extension list (e.g. "--langmap=Fortran:"). Torestore the default language mappings for all a particular language, supplythe keyword "default" for the mapping. To specify restore the default languagemappings for all languages, specify --langmap=default.
- --line-directives=yes|no
- Specifies whether "#line" directives should be recognized. These are presentin the output of preprocessors and contain the line number, and possibly thefile name, of the original source file(s) from which the preprocessor outputfile was generated. When enabled, this option will cause ctags togenerate tag entries marked with the file names and line numbers of theirlocations original source file(s), instead of their actual locations in thepreprocessor output. The actual file names placed into the tag file will havethe same leading path components as the preprocessor output file, since it isassumed that the original source files are located relative to thepreprocessor output file (unless, of course, the #line directive specifies anabsolute path). This option is off by default. Note: This option isgenerally only useful when used together with the --excmd=number(-n) option. Also, you may have to use either the --lang or--langmap option if the extension of the preprocessor output file is notknown to ctags.
- --links=yes|no
- Indicates whether symbolic links (if suppported) should be followed. Whendisabled, symbolic links are ignored. This option is on by default.
- --recurse=yes|no
- Recurse into directories encountered in the list of supplied files. If thelist of supplied files is empty and no file list is specified with the-L option, then the current directory (i.e. ".") is assumed. On Unix,directories named "SCCS" are skipped, because files in these directories arenot source code, even though they have the same names as the source code towhich they relate. Directories named "EIFGEN" are skipped, because thesecontain Eiffel compiler-generated C files. Also on Unix, symbolic links arefollowed. If you don't like these behaviors, either explicitly specify thefiles or pipe the output of find(1) into ctags -L- instead.Note: This option is not supported on all platforms at present.
- --sort=yes|no
- Indicates whether the tag file should be sorted on the tag name (default isyes). Note that the original vi(1) requires sorted tags. Thisoption is on by default. This option must appear before the first file name.[Ignored with -e]
- --totals=yes|no
- Prints statistics about the source files read and the tag file written duringthe current invocation of ctags. This option is off by default.This option must appear before the first file name.
- --verbose=yes|no
- Enable verbose mode. This prints out information on option processing and abrief message describing what action is being taken for each file consideredby ctags. Normally, ctags does not read command line argumentsuntil after options are read from the configuration files (see FILES,below) and the CTAGS environment variable. However, if this option isthe first argument on the command line, it will take effect before any optionsare read from these sources.
- --version
- Prints a version identifier for ctags to standard output. This isguaranteed to always contain the string "Exuberant Ctags".
OPERATIONAL DETAILS
For every one of the qualified objects which are discovered in the sourcefiles supplied to
ctags, a separate line is added to the tag file, eachlooking like this in the most general case:
- tag_name file_name ex_cmd;" xflags
The fields and separators of these lines are specified as follows:
- 1.
- tag name (a C language identifier)
- 2.
- a single tab character
- 3.
- the name of the file in which the object associated with the tag is located
- 4.
- a single tab character
- 5.
- an EX command to locate the tag within the file; generally a search pattern(either /pattern/ or ?pattern?) or line number (see --excmd). Tag fileformat 2 (see --format) extends this EX command under certaincircumstances to include a set of extension flags (see EXTENSION FLAGS,below) embedded in an EX comment immediately appended to the EX command, whichleaves it backwards compatible with original vi(1) implementations.
A few special tags are written into the tag file for internal purposes. Thesetags 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 todetect a tag file for purposes of determining whether a valid tag file isbeing overwritten rather than a source file.
When this program is invoked by the name etags, or with the -eoption, the output file is in a different format that is used by emacs(1).
Note that the name of each source file will be recorded in the tag fileexactly as it appears on the command line. Therefore, if the path youspecified on the command line was relative to some directory, then it willbe recorded in that same manner in the tag file.
This version of ctags imposes no formatting requirements. Other versionsof ctags tended to rely upon certain formatting assumptions in order to helpit resolve coding dilemmas caused by preprocessor conditionals.
In general, ctags tries to be smart about conditional preprocessordirectives. If a preprocessor conditional is encountered within a statementwhich defines a tag, ctags follows only the first branch of thatconditional (except in the special case of "#if 0", in which case it followsonly the last branch). The reason for this is that failing to pursue only onebranch can result in ambiguous syntax, as in the following example:
- #ifdef TWO_ALTERNATIVES
struct {
#else
union {
#endif- short a;
long b;
}
Both branches cannot be followed, or braces become unbalanced and ctagswould be unable to make sense of the syntax.
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 notselectively follow conditional preprocessor branches, but instead falls backto relying upon a closing brace ("}") in column 1 as indicating the end of ablock once any brace imbalance results from following a #if conditional branch.
Ctags will also try to specially handle arguments lists enclosed indouble sets of parentheses in order to accept the following conditionalconstruct:
- extern void foo __ARGS((int one, char two));
Any name immediately preceding the "((" will be automatically ignored andthe previous name will be used.
C++ operator definitions are specially handled. In order for consistency withall types of operators (overloaded and conversion), the operator name in thetag file will always be preceded by the string "operator " (i.e. even if theactual operator definition was written as "operator<<").
After creating or appending to the tag file, it is sorted by the tag name,removing identical tag lines.
Note that the path recorded for filenames in the tag file and utilized bythe editor to search for tags are identical to the paths specified forfile(s) on the command line. This means the if you want the paths forfiles to be relative to some directory, you must invoke ctags with thesame pathnames for file(s) (this can be overridden with -p).
EXTENSION FLAGS
Extension flags are tab-separated key-value pairs appended to the end of theEX command as a comment, as described above in OPERATIONAL DETAILS.These key value pairs appear in the general form "key:value".The possible keys and the meaning of their values are as follows:
- access
- Indicates the visibility of this class member, where value is specificto the language.
- class
- Indicates that this tag is a member of the class whose name is given byvalue.
- enum
- Indicates that this tag is a member of the enumeration whose name is given byvalue.
- file
- Indicates that the tag has a file-limited scope (i.e. is static to the file).This key has no corresponding value.
- kind
- Indicates the type of the tag. Its value is either one of the correspondingone-letter flags described under the various --<lang>-types optionsabove, or a full name, depending upon the value of the --kind-longoption. Alternatively, this key may be omitted, with only its value present(i.e. a field without a ':' defaults to the kind key).
- implementation
- When present, this indicates a limited implementation (abstract vs. concrete)of a routine or class, where value is specific to the language("virtual" or "pure virtual" for C++; "abstract" for Java).
- inherits
- When present, value. is a comma-separated list of classes from whichthis class is derived (i.e. inherits from).
- interface
- Indicates that this tag is a member of the interface whose name is given byvalue.
- namespace
- Indicates that this tag is a member of the namespace whose name is given byvalue.
- struct
- Indicates that this tag is a member of the structure whose name is given byvalue.
- union
- Indicates that this tag is a member of the union whose name is given byvalue.
ENVIRONMENT VARIABLES
- CTAGS
- If this enviroment variable exists, it will be expected to contain a set ofdefault options which are read when ctags starts, after theconfiguration files listed in FILES, below, are read, but before anycommand line options are read. Options appearing on the command line willoverride options specified in this file. Only options will be read from thisfile.
- ETAGS
- Similar to the CTAGS variable above, this variable, if found, will beread when etags starts. If this variable is not found, etags willtry to use CTAGS instead.
- TMPDIR
- On Unix-like hosts where mkstemp() is available, the value of this variablespecifies the directory in which to place temporary files. This can be usefulif the size of a temporary file becomes too large to fit on the partitionholding the default temporary directory defined at compilation time.ctags creates temporary files only if either (1) an emacs-style tag fileis 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 tagfiles instead of the the sort utility of the operating system. If the sortutility of the operating system is being used, it will generally observe thisvariable also. Note that if ctags is setuid, the value of TMPDIR will beignored.
HOW TO USE WITH VI
Vi will, by default, expect a tag file by the name "tags" in the currentdirectory. Once the tag file is built, the following commands exercise the tagindexing feature:
- vi -t tag
- Start vi and position the cursor at the file and line where "tag" is defined.
- Control-]
- Find the tag under the cursor.
- :ta tag
- Find a tag.
- Control-T
- Return to previous location before jump to tag (not widely implemented).
HOW TO USE WITH GNU EMACS
Emacs will, by default, expect a tag file by the name "TAGS" in the currentdirectory. Once the tag file is built, the following commands exercise thetag indexing feature:
- Meta-x visit-tags-table
- Visit a TAGS file.
- Meta-.
- Find a definition for a tag. The default tag is the identifier under thecursor. There is name completion in the minibuffer; typing "foo TAB"completes the identifier starting with `foo' (`foobar', for example) or liststhe alternatives.
- Meta-,
- Find the next definition for the tag. Exact matches are found first, followedby fuzzier matches.
For more commands, see the Tags topic in the Emacs info tree.
BUGS (CAVEATS)
Ctags has as many options as
ls(1).
Because ctags is neither a preprocessor nor a compiler, use ofpreprocessor macros can fool ctags into either missing tags orimproperly generating inappropriate tags. Although ctags has beendesigned to handle certain common cases, this is the single biggest cause ofreported problems. In particular, the use of preprocessor constructs whichalter the textual syntax of C can fool ctags. You can work around manysuch problems by using the -I option.
When parsing a C++ member function definition (e.g. "className::function"),ctags cannot determine whether the scope specifier is a class name or anamespace specifier and always lists it as a class name in the scope portionof the extension flags.
White space is treated as a separator for file names and options read fromlist files, specified using the -L option, and in filter mode (specifiedusing the --filter option). Therefore, it is not currently possible tosupply file names or other options containing embedded white space (spaces,etc.) through these options.
Legacy C source code which uses C++ reserved keywords as variable or parameternames (e.g. "class", etc.) in a header file may fail to have correct tagsgenerated for the objects using them. In order to properly handle such code,use the --lang option.
Note that when ctags generates uses patterns for locating tags (seethe --excmd option), it is entirely possible that the wrong line may befound by your editor if there exists another source line which is identical tothe line containing the tag. The following example demonstrates this condition:
- int variable;
/* ... */
void foo(variable)
int variable;
{
- /* ... */
}
Depending upon which editor you use and where in the code you happen to be, itis possible that the search pattern may locate the local parameter declarationin foo() before it finds the actual global variable definition, since thelines (and therefore their search patterns are identical). This can be avoidedby use of the --excmd=n option.
FILES
- /etc/ctags.conf
- /usr/local/etc/ctags.conf
- $HOME/.ctags
- .ctags
If any of these configuration files exist, each will be expected to contain aset of default options which are read in the order listed when ctagsstarts, but before the CTAGS enviroment variable is read or any commandline options are read. This makes it possible to set up site-wide, personalor project-level defaults. It is possible to compile ctags to read anadditional configuration file immediately before $HOME/.ctags, which will beindicated if the output produced by the --version option lists the"custom-conf" feature. Options appearing in the CTAGS enviromentvariable or on the command line will override options specified in thesefiles. Only options will be read from these files.- tags
- The default tag file created by ctags.
- TAGS
- The default tag file created by etags.
SEE ALSO
The official Exuberant Ctags web site at:
- http://darren.hiebert.com/ctags/index.html
Also ex(1), vi(1), elvis, or, better yet, vim, theofficial editor of ctags. For more information on vim, see the VIMPages web site at:
- http://www.vim.org/
AUTHOR
Darren Hiebert <
darren@hiebert.com>, <darrenAATThiwaay.net>
http://darren.hiebert.com/
MOTIVATION
"Think ye at all times of rendering some service to every member of the humanrace."
"All effort and exertion put forth by man from the fullness of his heart isworship, if it is prompted by the highest motives and the will to do serviceto humanity."
- -- From the Baha'i Writings
CREDITS
This version of
ctags was originally derived from and inspired by thectags program by Steve Kirkendall <kirkendaAATTcs.pdx.edu> that comes with theElvis vi clone (though virtually none of the original code remains).
Credit is also due Bram Moolenaar <BramAATTvim.org>, the author of vim, whohas devoted so much of his time and energy both to developing the editor as aservice to others, and to helping the orphans of Uganda.
The section entitled "HOW TO USE WITH GNU EMACS" was shamelessly stolen fromthe man page for GNU etags.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- SOURCE FILES
- OPTIONS
- OPERATIONAL DETAILS
- EXTENSION FLAGS
- ENVIRONMENT VARIABLES
- HOW TO USE WITH VI
- HOW TO USE WITH GNU EMACS
- BUGS (CAVEATS)
- FILES
- SEE ALSO
- AUTHOR
- MOTIVATION
- CREDITS
This document was created byman2html,using the manual pages.