Wiki
Version 2 (modified by Charles, 5 years ago)

--

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]*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 recognised with

966 xx:.../wkspace> ctags --list-kinds=Cobra
c  classes
m  methods
v  var
p  properties
967 xx:.../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