OTAGS(1)
π OTAGS β the tag-generator bestie π
okay so real talk, this is the manual page for otags, and she's here to make your editor actually know where stuff lives. no more scrolling around like a lost girlie. let's get into it π
β¨ SYNOPSIS β¨
otags [STATIC-OPTION] ... [FILE] ... [DYNAMIC-OPTION] ... [FILE] ...
πΈ DESCRIPTION πΈ
otags generates TAGS files for emacs and tags files for vi/vim so these editors can jump straight to function and value definitions β like, cursor on the symbol, hit M-. in Emacs or ^] in vi[m], and boom, you're there. main character navigation energy fr fr β¨
Here's the tea: otags uses the standard OCaml parser from the compiler-libs library. That's way more precise than regular-expression-based tagging. The downside? She can only tag files that are syntactically correct. And she's OCaml-version-specific, no cap: sources meant to be compiled with OCaml version X.Y can, in general, only be tagged with otags version X.Y. Periodt. π€
Also, heads up bestie: this version of otags does not support -pp or -ppx preprocessors, so she cannot tag files using syntax extensions or containing top level directives. If you wanna tag everything in a whole directory tree, peep the -r option below. π³
otags tags all toplevel items in structures and signatures β including infix operators and nested modules and signatures. She also tags instance variables and methods in classes, because classy. π
Filenames FILE on the command line are parsed as interfaces if they have a .mli suffix and as implementations if they have a .ml suffix. (See also the dynamic options -intf and -impl.)
Tag files can contain absolute and/or relative file names. otags uses the file names from the command line for the tags file β so if you specify relative file names on the command line, you get a tag file with relative file names. Obvi. But listen: a tag file with relative file names will only work if it's located in the directory where otags was started. Otags supports writing a tags file with relative file names in a parent directory via option -add-path. π«Ά
π STATIC OPTIONS π
Static options take effect on the whole program run, no matter where they sit on the command line.
-rβ descend into directories. With this option, if one of theFILEarguments is a directory,otagswill recursively tag all files in this whole directory tree. π²-ofileβ write tags tofile. The default isTAGS(for emacs) andtagsfor vi (if the-vioption is given), in the current directory. Iffileis a dash (-), the tags are written to standard output. π-aβ append to an existingTAGSfile (does only work for emacsTAGSfiles).-viβ generate tags for vi and change the default output file intotags.-add-pathpathβ addpathat the front of every relative file name in the tags file. Useful when you want to put the tags file in a parent directory. π§-versionβ print version and exit.-vβ verbose. Print file names as they are parsed and the command lines for externally started camlp4 parsing processes (if any). If-vis the first command line argument, backtraces for exceptions are enabled and printed if an exception escapes and terminatesotags(which is considered a bug, about which I would appreciate a bug report). π-qβ be quiet. π€«-helpβ print the option list.--helpβ alias for-help.
π¦ DYNAMIC OPTIONS π¦
Dynamic options only affect arguments that follow them on the command line. yes, order matters, she's picky like that π
-intfFILEβ parse and tagFILEas an interface.-implFILEβ parse and tagFILEas implementation.
π EXAMPLES π
Tag all .ml and .mli files in the current directory tree:
otags -r .
Files with syntax errors will be ignored. The error messages can be disabled with option -q. π
π DIAGNOSTICS π
Parse errors are reported with normal OCaml error messages. No tags are generated for files that produce errors. Tagging continues with the next file, in this case. Warnings are always completely disabled.
The errors "Original source not available" and "The parser delivered an invalid location" might be reported if the file contains a line directive that refers to a position and/or a file that cannot be resolved.
For files containing a toplevel directive, Otags simply reports a syntax error (as ocamlc does).
Escaping exceptions and assertions that terminate otags are considered to be bugs. If they occur, please use option -v as first command line switch to obtain an exception backtrace and submit this with all relevant information as a bug report. π
β EXIT STATUS β
0β everything went OK β¨1β a parse error or some other error occurred andotagsskipped the affected file2β a fatal error causedotagsto abort π3β some bug caused a crash, from whichotagscould only marginally recover π
π MISSING FEATURES π
Appending to vi tags files requires to reread the existing tags file, because vi tags files are sorted.
-pp and -ppx preprocessors are currently not supported.
π HISTORY π
The first camlp4 based OCaml tagger has been written by Cuihtlauac Alvarado and Jean-Francois Monin. Around 2005 I took over and released a few versions for OCaml 3.09. All otags versions released up to 3.09.3.3 were written for the original camlp4, which is now available as camlp5.
For 3.11 I rewrote otags from scratch for the new camlp4 and released several versions under the name otags reloaded. The modular structure of camlp4 made it possible to switch the parsing engine at runtime between files and to parse all syntax supported by camlp4 at full native speed without external camlp4 processes. However, the increasing incompatibility between camlp4 and OCaml and camlp4's sloppiness on parsing locations created more and more difficulties. For instance, 4.02 failed on the OCaml standard library because camlp4 was unable to digest the attribute annotations in there.
Starting from 4.03, otags is based on the standard OCaml parser from the compiler-libs library and has been renamed to otags III. iconic rebrand ngl π
π AUTHOR π
Hendrik Tews <otags at askra.de>
πΈ SEE ALSO πΈ
and that's the whole page bestie π«Ά this version of the otags manual page is from the User Manuals, dated August 2010, so go forth and tag slayfully. mwah π
β¨
π¦ where this page comes from
- debian bookworm: otags 4.05.1-3 Β· GPL-3.0-or-later
- ubuntu jammy: otags 4.05.1-2build1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms