Search code examples
cexuberant-ctags

Adding arbitrary/custom tags to (ex)ctags file


I have C code which contains references to requirement numbers of a very simple pattern:

/**
 * Lorem ipsum, you know the routine.
 * See also: Requirement R12345.
 */

In other words, the requirement is an R followed by exactly 5 decimal digits. I would like to add those to my ctags file so I can jump to tags with :ta R12345. I've read the exctags docs up and down, but could not find any option that would allow this.

I thought of grepping for the requirements and patching up the tags file with appropriate lines (using search for line numbers probably makes this easy) but I am not sure if the extra lines would need to be merged or just appended, and what the exact format is.


Solution

  • I must be blind not recognizing the --regex-<LANG> option. This does exactly what I want:

    ctags ... --regex-c='/\<(R[[:digit:]]{5})\>/\1/' *.[ch]
    

    This creates the tags file with additional tags for all R12345 requirements.