Search code examples
commentswarningsctagsexuberant-ctags

How to add comments to an Exuberant Ctags config file?


What character can I use to put comments in an Exuberant Ctags .ctags file?

I would like to add comments with explanations, and perhaps to disable some regexps.

But I can't find any comment character which ctags-exuberant accepts!
I keep getting the warning:

ctags: Warning: Ignoring non-option in /home/joey/.ctags

which is better than an error, but still a little annoying.

I have tried # // /* ... */ and ; as comments, but ctags tries to parse them all!

Here is an example file with some comments which ctags will complain about:

# Add some more rules for Javascript
--langmap=javascript:+.jpp
--regex-javascript=/^[ \t]*var ([a-zA-Z_$][0-9a-zA-Z_$]*).*$/\1/v,variable/
--regex-javascript=/^[ \t]*this\.([a-zA-Z_$][0-9a-zA-Z_$]*)[ \t]*=.*$/\1/e,export/
--regex-javascript=/^[ \t]*([a-zA-Z_$][0-9a-zA-Z_$]*):.*$/\1/p,property/
--regex-javascript=/^\<function\>[ \t]*([a-zA-Z_$][0-9a-zA-Z_$]*)/\1/f,function/

# Define tags for the Coffeescript language
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^class @?([a-zA-Z_$][0-9a-zA-Z_$]*)( extends [a-zA-Z_$][0-9a-zA-Z_$]*)?$/\1/c,class/
--regex-coffee=/^[ \t]*(@|this\.)([a-zA-Z_$][0-9a-zA-Z_$]*).*$/\2/e,export/
--regex-coffee=/^[ \t]*@?([a-zA-Z_$][0-9a-zA-Z_$]*):.*[-=]>.*$/\1/f,function/
--regex-coffee=/^[ \t]*([a-zA-Z_$][0-9a-zA-Z_$]*)[ \t]+=.*[-=]>.*$/\1/f,function/
--regex-coffee=/^[ \t]*([a-zA-Z_$][0-9a-zA-Z_$]*)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@?([a-zA-Z_$][0-9a-zA-Z_$]*):.*$/\1/p,property/

Solution

  • As @joeytwiddle points out, comments are not supported by the parser, but there is a work-around.

    Example .ctags file:

    --regex-C=/$x/x/x/e/ The ctags parser currently doesn't support comments
    --regex-C=/$x/x/x/e/ This is a work-around which works with '/' characters
    --regex-C=/$x/x/x/e/ http://stackoverflow.com/questions/10973224/how-to-add-comments-to-an-exuberant-ctags-config-file
    --regex-C=/$x/x/x/e/ 
    --regex-C=/$x/x/x/e/ You can add whatever comment text you want here.