ctags [-aCdgImRVh] [-BtTuvwx] [-l language] [-o tagfile] [-r regexp] [--append] [--backward-search] [--cxref] [--defines] [--forward-search] [--globals] [--ignore-indentation] [--language=language] [--members] [--output=tagfile] [--regex=regexp] [--ignore-case-regex=regexp] [--typedefs] [--typedefs-and-c++] [--update] [--no-warn] [--help] [--version] file ...
where tagregexp is used to match the lines that must be tagged. It should not match useless characters. If the match is such that more characters than needed are unavoidably matched by tagregexp, it may be useful to add a nameregexp, to narrow down the tag scope. ctags ignores regexps without a nameregexp. The syntax of regexps is the same as in emacs, augmented with intervals of the form \{m,n\}, as in ed or grep. Here are some examples. All the regexps are quoted to protect them from shell interpretation.
Tag the DEFVAR macros in the emacs source files: --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
Tag VHDL files (this example is a single long line, broken here for formatting reasons): --language=none --regex='/[ \t]*\(ARCHITECTURE\|\ CONFIGURATION\) +[^ ]* +OF/' --regex='/[ \t]*\ \(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\( BODY\)?\ \|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
Tag TCL files (this last example shows the usage of a tagregexp): --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
A regexp can be preceded by {lang}, thus restricting it to match lines of files of the specified language. Use etags --help to obtain a list of the recognised languages. This feature is particularly useful inside regex files. A regex file contains one regex per line. Empty lines, and those lines beginning with space or tab are ignored. Lines beginning with @ are references to regex files whose name follows the @ sign. Other lines are considered regular expressions like those following --regex. For example, the command etags --regex=@regex.file *.c reads the regexes contained in the file regex.file.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and no Back-Cover Texts.
This document is part of a collection distributed under the GNU Free Documentation License. If you want to distribute this document separately from the collection, you can do so by adding a copy of the license to the document, as described in section 6 of the license. A copy of the license is included in the gfdl(1) man page, and in the section entitled "GNU gfdl(1) man page, and in the section entitled "GNU Free Documentation License" in the Emacs manual.