I recently installed cscope Vim plugin to make it easier to jump through code, but the main functionality – go to line, does not work. I have F2 key mapped to “Find all references”. When I select a function call for example, and press F2, I get the list of all the references, and the first reference is usually the function definition. When I type the line number and press Enter, nothing happens, and it is supposed to jump to the line I typed in. What could possibly be the problem here? Do I need to make some additional changes to my vimrc file to make the jumping possible?
Advertisement
Answer
When I type the line number and press Enter, nothing happens, and it is supposed to jump to the line I typed in
You actually should type the number that appears on the first column. The cscope usage is explained in detail at :help cscope-commands
. It also provides the following example:
: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.
You are supposed to type a number between 1 and 15; any other just cancel the command.