vimctagsuniversal-ctags

universal ctags with vim for c++


I have recently started working on a huge c++ codebase and I am unable to use ctags(universal-ctags) properly. Whenever I do CTRL+] on a method, it jumps to the namespace definition. But I want it to jump to the definition of the method under the cursor.

I generated the tags file using the following:

ctags -R --sort=no --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ .

I would really appreciate any help regarding this or is there any better way to navigate c++ code other than ctags.


Solution

  • Do ctags --list-kinds=C++ to see what can be tagged and what is enabled by default. Note n next to "namespaces". Therefore to disable tagging of namespaces, you should replace --c++-kinds=+p with --c++-kinds=+p-n in your command used to generate tags:

    ctags -R --sort=no --c++-kinds=+p-n --fields=+iaS --extra=+q --language-force=C++ 
    

    If you don't want to disable tagging of namespaces, do g] on a method instead of CTRL-]. You can then enter a number to select the tag you want. Note the "type" column. Select the one with f if you want to jump to the function or method.