开发者

Vim: goto function definition

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.


Use g] to get a picklist first


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜