【发布时间】:2015-07-15 09:03:53
【问题描述】:
我最近安装了 cscope Vim 插件,以便更轻松地跳转代码,但主要功能 - 转行,不起作用。 我将 F2 键映射到“查找所有引用”。例如,当我选择一个函数调用并按 F2 时,我会得到所有引用的列表,而第一个引用通常是函数定义。当我输入行号并按 Enter 时,什么也没有发生,它应该跳到我输入的行。这里可能有什么问题?我是否需要对我的 vimrc 文件进行一些额外的更改才能使跳转成为可能?
【问题讨论】:
我最近安装了 cscope Vim 插件,以便更轻松地跳转代码,但主要功能 - 转行,不起作用。 我将 F2 键映射到“查找所有引用”。例如,当我选择一个函数调用并按 F2 时,我会得到所有引用的列表,而第一个引用通常是函数定义。当我输入行号并按 Enter 时,什么也没有发生,它应该跳到我输入的行。这里可能有什么问题?我是否需要对我的 vimrc 文件进行一些额外的更改才能使跳转成为可能?
【问题讨论】:
当我输入行号并按 Enter 时,什么也没有发生,它 应该跳到我输入的行
您实际上应该输入出现在第一列的数字。 cscope 用法在:help cscope-commands 有详细说明。它还提供了以下示例:
:cscope find 0 DEFAULT_TERM
Executing this example on the source code for Vim 5.1 produces the
following output:
Cscope tag: DEFAULT_TERM
# line filename / context / line
1 1009 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"amiga"
2 1013 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"win32"
3 1017 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"pcterm"
4 1021 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"ansi"
5 1025 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"vt52"
6 1029 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"os2ansi"
7 1033 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"ansi"
8 1037 vim-5.1-gtk/src/term.c <<GLOBAL>>
# undef DEFAULT_TERM
9 1038 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"beos-ansi"
10 1042 vim-5.1-gtk/src/term.c <<GLOBAL>>
#define DEFAULT_TERM (char_u *)"mac-ansi"
11 1335 vim-5.1-gtk/src/term.c <<set_termname>>
term = DEFAULT_TERM;
12 1459 vim-5.1-gtk/src/term.c <<set_termname>>
if (STRCMP(term, DEFAULT_TERM))
13 1826 vim-5.1-gtk/src/term.c <<termcapinit>>
term = DEFAULT_TERM;
14 1833 vim-5.1-gtk/src/term.c <<termcapinit>>
term = DEFAULT_TERM;
15 3635 vim-5.1-gtk/src/term.c <<update_tcap>>
p = find_builtin_term(DEFAULT_TERM);
Enter nr of choice (<CR> to abort):
The output shows several pieces of information:
1. The tag number (there are 15 in this example).
2. The line number where the tag occurs.
3. The filename where the tag occurs.
4. The context of the tag (e.g., global, or the function name).
5. The line from the file itself.
您应该输入一个介于 1 和 15 之间的数字;任何其他的只是取消命令。
【讨论】: