4

How do I jump to the declaration of a C++ method instead of the definition using :tag or C-]? I tried

ctags * --C++-kinds=+p

to generate the tags file but :tselect still does not list any declarations, only definitions. The header files are hpp files and source files are cpp files, all in the same directory.

I have seen this answer but it does not answer my question, except for a comment from where I got the above idea (--<LANG>-kinds).

Aditya Kashi
  • 246
  • 2
  • 13

1 Answers1

4

I'm using the following options: --c++-kinds=+pf --fields=+imaSft --extras=+q. Among many other things, I see function definitions and function declarations.

I handle everything automatically in a plugin I've been maintaining for quite some time.

On the same subject, see also:

BTW, I highly recommend using universal-ctags (the maintained fork) instead of exhuberant ctags (the venerable and unmaintained project) when trying to generate tags for C++.

Luc Hermitte
  • 29,719
  • 7
  • 60
  • 74
  • Does this work only with universal-ctags? I tried this with exuberant but `extras` is not supported. I tried without it (only kinds and fields) but I still don't get declarations. Thanks for pointing me to universal-ctags, though. – Aditya Kashi Oct 12 '17 at 15:49
  • Indeed. Sorry, It used to be `extra` with ex-ctags. – Luc Hermitte Oct 12 '17 at 22:49
  • 1
    Great, thanks! `--c++-kinds=+pf --extra=+q` was enough to make it jump to prototypes first and to display prototypes when I do `g C-]`. Is there a way to keep prototype tags but have it jump to definitions first? – Aditya Kashi Oct 13 '17 at 23:11