Okay I've done it:
It all has to do with ctags
:
First create two files called foo.c
and foo.h
to test it:
In foo.h
write down:
int bar(void);
In foo.c
write down:
int bar(void) { /* */ }
And in the directory where those two files is, execute:
ctags --list-kinds
You get a long list of languages with there types of tags. Find C. Notice the following line:
p function prototypes [off]
I would call it function declaration but anyway. So you need to activate tags for function prototypes when executing ctags
. You do that by calling:
ctags -R --c-kinds=+p
Notice that the same applies to any other languages, e.g.:
ctags -R --java-kinds=+l
Now you can open foo.c
(vim foo.c
) and enter :tag bar
. It will show you the function definition. Enter :tnext
and you will jump into foo.h
to the declaration of bar
.
However also notice that ctags
doesn't care about correctness. E.g. the bar
declaraction couldn't even apply to the definition of bar
, as I havn't included the header file.
ctags
? Also, see:h gD
.ctags -R
, that was the mistake