Ctags

Ctags
Ctags
Developer(s) Ken Arnold
Type tag file generator

Ctags is a program that generates an index (or tag) file of names found in source and header files of various programming languages. Depending on the language, functions, variables, class members, macros and so on may be indexed. These tags allow definitions to be quickly and easily located by a text editor or other utility. Alternatively, there is also an output mode that generates a cross reference file, listing information about various names found in a set of language files in human-readable form.

The original Ctags was introduced in BSD Unix and was written by Ken Arnold, with Fortran support by Jim Kleckner and Pascal support by Bill Joy.

Contents

Editors that support ctags

Tag index files are supported by many source code editors, including:

Variants of ctags

There are a few variations of the ctags program:

Etags

Etags is the ctags utility that comes with Emacs. For those options which only make sense for vi style tag files produced by ctags, etags could not recognize them and would ignore them.

Exuberant Ctags

Exuberant Ctags, written and maintained by Darren Hiebert, was initially distributed with Vim, but became a separate project upon the release of Vim 6.[1] It includes support for Emacs compatibility.

Exuberant Ctags includes support for over 40 programming languages with the ability to add support for even more using regular expressions.

Hasktags

Hasktags creates ctags compatible tag files for Haskell source files.[2] It includes support for creating Emacs etags files.[3]

jsctags

jsctags is a ctags-compatible code indexing solution for JavaScript.[4] It is specialized for JavaScript and its packaging system CommonJS and outperforms Exuberant Ctags for JavaScript code, finding more tags than the latter.[5]

Tags file formats

There are multiple tag file formats. Some of them are described below. In the following, <\x##> represents the byte with hexadecimal representation ##.

Ctags and Exuberant Ctags

The original ctags and Exuberant Ctags have similar file formats:[6]

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:

{tagname}<Tab>{tagfile}<Tab>{tagaddress}

The fields are specified as follows:

  • {tagname} – Any identifier, not containing white space
  • <Tab> – Exactly one tab character, although many versions of vi can handle any amount of white space
  • {tagfile} – The name of the file where {tagname} is defined, relative to the current directory
  • {tagaddress} – 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.

The tags file is sorted on the {tagname} field which allows for fast searching of the tags file.

Exuberant Ctags

This is the format used by Vim. It can generate an original ctags file format or an extended format that attempts to retain backward compatibility.

The fields are specified as follows:

{tagname}<Tab>{tagfile}<Tab>{tagaddress}[;"<Tab>{tagfield}...]

The fields up to and including {tagaddress} are the same as for ctags above.

Optional additional fields:

  • ;" – semicolon + doublequote: Ends the {tagaddress} in way that looks like the start of a comment to vi.
  • {tagfield}

Extended format extends the {tagaddress} field under certain circumstances to include a set of extension fields embedded in an ex comment immediately appended to the ex command, which leaves it backward-compatible with original vi implementations. These extension fields are tab separated "key:value" pairs, documented in the ctags manual.

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-ascii characters used for special purposes. These characters are represented as bracketed hexadecimal codes below.

A section starts with a two line header, one line containing a single <\x0c> character, followed by a line which consists of:

{src_file},{size_of_tag_definition_data_in_bytes}

The header is followed by tag definitions, one definition per line, with the format:

{tag_definition_text}<\x7f>{tagname}<\x01>{line_number},{byte_offset}

{tagname} (along with \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 file would look like this:

<\x0c>
test.c,21
#define CCC(<\x7f>CCC<\x01>1,0

References

  1. ^ "Vim documentation: version6: ctags-gone". http://vimdoc.sourceforge.net/htmldoc/version6.html#ctags-gone. Retrieved 2007-04-28. 
  2. ^ "GHC documentation: Other Haskell utility programs". http://haskell.org/ghc/docs/latest/html/users_guide/utils.html#hasktags. Retrieved 2010-03-05. 
  3. ^ "hasktags: Produces ctags "tags" and etags "TAGS" files for Haskell programs". http://hackage.haskell.org/package/hasktags. Retrieved 2010-03-05. 
  4. ^ "pcwalton github repository for jsctags". http://github.com/pcwalton/jsctags. 
  5. ^ Patrick Walton. "Introducing jsctags". http://pcwalton.blogspot.com/2010/05/introducing-jsctags.html. Retrieved 2010-05-25. 
  6. ^ "Proposal for extended Vi tags file format". http://ctags.sourceforge.net/FORMAT. Retrieved 2007-06-30. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Ctags — ctags  утилита, собирающая информацию об именах и позициях переменных, функций и процедур, встречающихся в исходном коде компьютерных программ. При этом генерируется тег файл (англ. tag file), формат которого поддерживается большим… …   Википедия

  • ctags — Тип утилита навигации по исходному коду Разработчик Ken Arnold Операционная система Unix подобные операционные системы ctags  утилита, собирающая информацию об именах и позициях переменных, функций и процедур, встречающихся в исходном коде… …   Википедия

  • Marqueurs (edition de texte) — Marqueurs (édition de texte) Un marqueur (tag en anglais) est un mot clef remarquable dans un fichier texte, que le rédacteur ou le lecteur est susceptible de vouloir rechercher. La caractéristique lui conférant cette qualité dépend de la nature… …   Wikipédia en Français

  • Marqueurs (édition de texte) — Un marqueur (tag en anglais) est un mot clef remarquable dans un fichier texte, que le rédacteur ou le lecteur est susceptible de vouloir rechercher. La caractéristique lui conférant cette qualité dépend de la nature du texte qui le contient.… …   Wikipédia en Français

  • Marqueur (édition de texte) — Un marqueur (tag en anglais) est un mot clé remarquable dans un fichier texte, que le rédacteur ou le lecteur est susceptible de vouloir rechercher. La caractéristique lui conférant cette qualité dépend de la nature du texte qui le contient.… …   Wikipédia en Français

  • Comparison of text editors — This article provides basic comparisons for common text editors. More feature details for text editors are available from the Category of text editor features and from the individual products articles. This article may not be up to date or… …   Wikipedia

  • NEdit — 5.5 with tabbed interface. Stable release 5.5 / October 3, 2004; 7 years ago …   Wikipedia

  • Программы UNIX-подобных операционных систем — Это список популярных программ, работающих в операционных системах основанных на UNIX (POSIX совместимых). Некоторые из этих программ являются стандартными для UNIX подобных систем. Содержание 1 Системный софт 1.1 Общего назначения …   Википедия

  • NEdit — Тип Текстовый редактор Написана на C Операционная система UNIX подобные Последняя версия 5.5 (13 октября 2004) Лицензия GPL …   Википедия

  • CodeLite — Тип IDE Разработчик E …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”