Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 781
claw107 Avatar asked Apr 25 '26 16:04

claw107


1 Answers

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.

like image 52
gdupras Avatar answered Apr 28 '26 16:04

gdupras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!