Ctags
   HOME

TheInfoList



OR:

Ctags is a
programming tool A programming tool or software development tool is a computer program that software developers use to create, debug, maintain, or otherwise support other programs and applications. The term usually refers to relatively simple programs, that can b ...
that generates an
index Index (or its plural form indices) may refer to: Arts, entertainment, and media Fictional entities * Index (''A Certain Magical Index''), a character in the light novel series ''A Certain Magical Index'' * The Index, an item on a Halo megastru ...
(or tag) file of names found in source and header files of various
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
s to aid code comprehension. Depending on the language, functions, variables,
class Class or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used differentl ...
members, macros and so on may be indexed. These tags allow definitions to be quickly and easily located by a
text editor A text editor is a type of computer program that edits plain text. Such programs are sometimes known as "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be us ...
, a code search engine, or other utility. Alternatively, there is also an output mode that generates a
cross reference The term cross-reference (abbreviation: xref) can refer to either: * An instance within a document which refers to related information elsewhere in the same document. In both printed and online dictionaries cross-references are important because ...
file, listing information about various names found in a set of language files in
human-readable A human-readable medium or human-readable format is any encoding of data or information that can be naturally read by humans. In computing, ''human-readable'' data is often encoded as ASCII or Unicode text, rather than as binary data. In most c ...
form. The original Ctags was introduced in
BSD Unix The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
3.0 and was written by
Ken Arnold Kenneth Cutts Richard Cabot Arnold (born 1958) is an American computer programmer well known as one of the developers of the 1980s dungeon-crawling video game '' Rogue'', for his contributions to the original Berkeley (BSD) distribution of Uni ...
, with Fortran support by Jim Kleckner and
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, Fren ...
support by
Bill Joy William Nelson Joy (born November 8, 1954) is an American computer engineer and venture capitalist. He co-founded Sun Microsystems in 1982 along with Scott McNealy, Vinod Khosla, and Andy Bechtolsheim, and served as Chief Scientist and CTO at ...
. It is part of the initial release of Single Unix Specification and XPG4 of 1992.


Editors that support ctags

''Tag index files'' are supported by many
source code editor A source-code editor is a text editor program designed specifically for editing source code of computer programs. It may be a standalone application or it may be built into an integrated development environment (IDE) or web browser. Source-code ed ...
s, including: *
Atom Every atom is composed of a nucleus and one or more electrons bound to the nucleus. The nucleus is made of one or more protons and a number of neutrons. Only the most common variety of hydrogen has no neutrons. Every solid, liquid, gas, and ...
* BBEdit 8+ *
CodeLite CodeLite is a free and open-source IDE for the C, C++, PHP, and JavaScript (Node.js) programming languages. History In August 2006, Eran Ifrah started an autocomplete project named CodeLite. The idea was to create a code completion library b ...
(via built-in ctagsd language server) *
Cloud9 IDE Cloud9 IDE is an Online IDE (integrated development environment), published as open source from version 2.0, until version 3.0. It supports multiple programming languages, including C, C++, PHP, Ruby, Perl, Python, JavaScript with Node.js, ...
(uses it internally but does not expose it) *
CygnusEd CygnusEd is a text editor for the Amiga OS and MorphOS. It was first developed in 1986-1987 by Bruce Dawson, Colin Fox and Steve LaRocque who were working for CygnusSoft Software. It was the first Amiga text editor with an undo/redo feature and on ...
*
Emacs Emacs , originally named EMACS (an acronym for "Editor MACroS"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
and
XEmacs XEmacs is a graphical- and console-based text editor which runs on almost any Unix-like operating system as well as Microsoft Windows. XEmacs is a fork, based on a version of GNU Emacs from the late 1980s. Any user can download, use, and modify X ...
* EmEditor Professional *
Far Manager Far Manager (short for ''File and ARchive Manager'') is an orthodox file manager for Microsoft Windows and is a clone of Norton Commander. Far Manager uses the Win32 console and has a keyboard-oriented user interface (although limited mouse o ...
(via Ctags Source Navigator plugin) *
Geany Geany ( IPA:dʒiːni ) is a free and open-source lightweight GUI text editor using Scintilla and GTK, including basic IDE features. It is designed to have short load times, with limited dependency on separate packages or external librarie ...
*
Gedit gedit ( or ) is a text editor designed for the GNOME desktop environment. It was GNOME's default text editor and part of the GNOME Core Applications until GNOME version 42 in March 2022, which changed the default text editor to GNOME Text E ...
(vi
gedit-symbol-browser-plugin
*
JED Jed or JED may refer to: Places * Jed River, New Zealand * Jed Water, a river in Scotland * Jed, West Virginia, United States, an unincorporated community People and fictional characters * Jed (given name), a list of people and fictional charact ...
* jEdit (via plugins CodeBrowser, Tags, ClassBrowser, CtagsSideKick, or Jump) *
JOE Joe or JOE may refer to: Arts Film and television * ''Joe'' (1970 film), starring Peter Boyle * ''Joe'' (2013 film), starring Nicolas Cage * ''Joe'' (TV series), a British TV series airing from 1966 to 1971 * ''Joe'', a 2002 Canadian animated ...
*
KDevelop KDevelop is a free and open-source integrated development environment (IDE) for Unix-like computer operating systems and Windows. It provides editing, navigation and debugging features for several programming languages, and integration with buil ...
*
Kate Kate name may refer to: People and fictional characters * Kate (given name), a list of people and fictional characters with the given name or nickname * Gyula Káté (born 1982), Hungarian amateur boxer * Lauren Kate (born 1981), American autho ...
* mcedit (Midnight Commander builtin editor) * NEdit *
Notepad++ Notepad++ is a text and source code editor for use with Microsoft Windows. It supports tabbed editing, which allows working with multiple open files in a single window. The product's name comes from the C postfix increment operator. Notepad++ ...
(via OpenCTags plug-in) * QDevelop * TSE (via macro) *
TextMate TextMate is a general-purpose Graphical user interface, GUI text editor for macOS created by Allan Odgaard. TextMate features declarative programming, declarative customizations, Tab (GUI), tabs for open documents, recordable Macro (computer scien ...
(via CodeBrowser-PlugIn) *
UltraEdit UltraEdit is a commercial text editor for Microsoft Windows, Linux and OS X created in 1994 by the founder of IDM Computer Solutions Inc., Ian D. Mead, and owned by Idera, Inc. since August 2021. The editor contains tools for programmers, includi ...
*
TextPad TextPad is a text editor for Microsoft Windows developed by Helios Software Solutions. It is currently in its eighth major version. TextPad was initially released in 1992 as shareware, with users requested to pay a registration fee to support ...
*
VEDIT Vedit is a commercial text editor for 8080/Z-80-based systems, Microsoft Windows and MS-DOS from Greenview Data, Inc. Vedit was one of the pioneers in visual editing. It used a command set resembling TECO. History Vedit (Visual Editor) was ...
* vi (and derivatives such as
Elvis Elvis Aaron Presley (January 8, 1935 – August 16, 1977), or simply Elvis, was an American singer and actor. Dubbed the "Honorific nicknames in popular music, King of Rock and Roll", he is regarded as Cultural impact of Elvis Presley, one ...
,
Nvi NVI or nvi may refer to: * nvi, a text editor * Avial NV, an airline * ''no value indicator'', a non-denominated postage stamp * Navoiy Airport, in Uzbekistan * Negative volume index, a financial analysis method * ''Nationale Vliegtuig Indust ...
, Vim, vile, etc.) *
Visual Studio Code Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code complet ...
* Xedit (X11)


Variants of ctags

There are a few other implementations of the ''ctags'' program:


Etags

GNU
Emacs Emacs , originally named EMACS (an acronym for "Editor MACroS"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
comes with two ctags utilities, etags and ctags, which are compiled from the same source code. Etags generates a tag table file for Emacs, while the ctags command is used to create a similar table in a format understood by vi. They have different sets of command line options: etags does not recognize and ignores options which only make sense for vi style tag files produced by the ctags command.


Exuberant Ctags

Exuberant Ctags, written and maintained by Darren Hiebert until 2009, was initially distributed with Vim, but became a separate project upon the release of Vim 6. It includes support for Emacs and compatibility. Exuberant Ctags includes support for over 40 programming languages with the ability to add support for even more using
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or ...
s.


Universal Ctags

Universal Ctags is a fork of Exuberant Ctags, with the objective of continuing its development. A few parsers are rewritten to better support the languages.


Language-specific

creates ctags compatible tag files for
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
source files. It includes support for creating Emacs etags files. is a ctags-compatible code indexing solution for
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
. It is specialized for JavaScript and uses the
CommonJS CommonJS is a project with the goal to establish conventions on the module ecosystem for JavaScript outside of the web browser. The primary reason for its creation was a major lack of commonly accepted forms of JavaScript module units which could ...
packaging system. It outperforms ''Exuberant Ctags'' for JavaScript code, finding more tags than the latter.


Tags file formats

There are multiple tag file formats. Some of them are described below. In the following, represents the byte with hexadecimal representation . Every line ends with a
line feed Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
(LF, = ).


Ctags and descendants

The original ''ctags'' and the Exuberant/Universal descendants have similar file formats:


Ctags

This is the format used by ''vi'' and various clones. The tags file is normally named "tags". The tags file is a list of lines, each line in the format: \t\t The fields are specified as follows: * – Any identifier, not containing white space * – Exactly one tab () character, although many versions of ''vi'' can handle any amount of white space. * – The name of the file where is defined, relative to the current directory * – An ex mode command that will take the editor to the location of the tag. For POSIX implementations of ''vi'' this may only be a search or a line number, providing added security against arbitrary command execution. The tags file is sorted on the field which allows for fast searching of the tags file.


Extended Ctags

This is the format used by Vim's Exuberant Ctags and Universal Ctags. These programs can generate an original ''ctags'' file format or an extended format that attempts to retain backward compatibility. The extended tags file is a list of lines, each line in the format: \t\t t.html" ;"title=""\t">"\t The fields up to and including are the same as for
ctags Ctags is a programming tool that generates an index (or tag) file of names found in source and header files of various programming languages to aid code comprehension. Depending on the language, functions, variables, class members, macros a ...
above. Optional additional fields are indicated by square brackets (" ..) and include: * – semicolon + double quote: Ends the in a way that looks like the start of a comment to ''vi'' or ''ex''. * – extension fields: tab separated "key:value" pairs for more information. This format is compatible with non-POSIX ''vi'' as the additional data is interpreted as a comment. POSIX implementations of ''vi'' must be changed to support it, however.


Etags

This is the format used by Emacs ''etags''. The tags file is normally named "TAGS". The etags files consists of multiple sections—one section per input source file. Sections are plain-text with several non-printable ascii characters used for special purposes. These characters are represented as underlined hexadecimal codes below. A section starts with a two line header (the first two bytes make up a magic number): \x0c , The header is followed by tag definitions, one definition per line, with the format: \x7f\x01, can be omitted if the name of the tag can be deduced from the text at the tag definition.


Example

Given a single line test.c source code: #define CCC(x) The TAGS (etags) file would look like this: \x0c test.c,21 #define CCC(\x7fCCC\x011,0 The tags (ctags) file may look like:
CCC(	test.c	1
or more flexibly using a search:
CCC(	test.c	/^#define CCC(/


See also

* GNU GLOBAL


References


External links

*
Universal Ctags homepage

Exuberant Ctags homepage

Ctags on VMS

source code for Emacs vtags.el module
{{Unix commands Code comprehension tools Code navigation tools Free computer programming tools Unix programming tools Standard Unix programs Unix SUS2008 utilities Software using the BSD license fr:Ctags