Wiki

Exuberant Ctags

ctags is a tool for making a file of jump tags from a set of (C) Sources.
A tags aware editor can then use the tags file to jump to another file and position when a tag is activated.
Normally this is configured so that activating a tag on function or method call takes you to the place of its definition.

 Exuberant ctags is an implementation and extension of this idea supporting multiple languages.

The following code is a quick and dirty configuration to allow ctags to make tags for cobra files.

Install the following in file $HOME/.ctags

--langdef=Cobra
--langmap=Cobra:.cobra
--regex-cobra=/^[ \t]*namespace[ \t]*([a-zA-Z0-9_\.]+)/\1/n,namespaces/
--regex-cobra=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/
--regex-cobra=/^[ \t]*struct[ \t]*([a-zA-Z0-9_]+)/\1/s,structs/
--regex-cobra=/^[ \t]*interface[ \t]*([a-zA-Z0-9_]+)/\1/i,interfaces/
--regex-cobra=/^[ \t]*extend[ \t]*([a-zA-Z0-9_\.]+)/\1/E,extensions/
--regex-cobra=/^[ \t]*enum[ \t]*([a-zA-Z0-9_]+)/\1/e,enums/
--regex-cobra=/^[ \t]*sig[ \t]*([a-zA-Z0-9_]+)/\1/S,method signatures/
--regex-cobra=/^[ \t]*def[ \t]*([a-zA-Z0-9_]+)/\1/m,methods/
--regex-cobra=/^[ \t]*var[ \t]*([a-zA-Z0-9_]+)/\1/v,vars/
--regex-cobra=/^[ \t]*(get|set|pro)[ \t]*([a-zA-Z0-9_]+)/\2/p,properties/
--sort=no

You can check that the above is recognized with

.../wkspace> ctags --list-kinds=Cobra
n  namespaces 
c  classes 
s  structs 
i  interfaces 
e  enums 
S  method signatures 
m  methods 
v  vars 
p  properties 
.../wkspace>

thereafter running

ctags -R *.cobra

in a cobra source tree should generate a file tags in the cwd containing tags for the cobra classes, methods, vars and properties recognised.

Running a tags aware editor that can find that tags file should give a simple jump navigation capability in that editor.
The ctags website above includes a list of (common) text editors that are ctags aware.

To Do

  • More testing
  • Indexers?
  • Show specific examples of using a ctags-aware editors

See Also