Search code examples
ctags

How do you make ctags more efficient for generating tags for C++ code


I always used ctags -nR to generate ctags and believed that this should be sufficient. But I now find that its struggling with C++ code where there are too many matches. Does it need more options to be sent in the command line to make it efficient.

I find eclipse to be a bit better although I believe it needs location of headers etc to be specified for existing projects with Makefile.

 ctags -nR

Is this any different from exuberant ctags or is it just an improvement. Request to not reject or close this question as a non programming question because I am sure programmers use such tools extensively and people in S.O would be the right audience to be able to answer this for they would have used it too as Linux programmers.


Solution

  • I'd struggled with this as well. The problem here is certainly the C++ part. ctags does not support it that well and many times it finds string matches instead of global definitions. What really worked for me was to replace standard/exuberant ctags with universal-ctags. C/C++ support has been polished a lot. It does work with additional languages by default. I've been using it mainly for Go and C and it does work like a charm.

    Here is the link: https://github.com/universal-ctags/ctags

    If you have your ctags environment set up, probably you only need to run the standard configure/make/make install and you're good to go!