3

I know the way to go to the function declaration (using ctags + Ctrl + ]). But what if I want not to go to the function declaration, but to the function definition instead.

For example:

// foo.c
#include "foo.h"

...
if (x > 3) foo_function(x);
...

void foo_function(int x) {
    ...
}

and

// foo.h
void foo_function(int x);

Then Ctrl + ] opens foo.h and points to the void foo_function(int x); line. I want to go to the foo.c to the foo_function definition. I have taglist installed, but don't want to open the taglist window every time I just want to jump to the function definition under cursor. Is there a way to do this with a keymap?

Thanks.

2

3 Answers 3

4

Use g] to get a picklist first

1

If you add the mappings suggested in :help cscope-suggestions, then you can use ^- g (control minus, then g -- nicely enough, even though the mappings were defined with <C-_>, vim lets you skip the shift key) to find the definition of the function under the cursor.

You could of course use any key mappings; I've seen control+\ as the default mapping in a cscope plugin.

1

As similar question was already asked on stack overflow:

Get ctags in vim to go to definition, not declaration

You may find answers there helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.