0

I read the code of redis with vim and build the database like this:

find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files
cscope -bq -i cscope.files -f cscope.out

and map keys in vim:

nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>

When I read src/dict.c and want to find the definition of function _dictInit, it should locate to the definition at src/dict.c, but actually it locate to the definition at deps/hiredis/dict.c, which has the same name function definition

So how should I fix the problem?

solomon_wzs
  • 1,711
  • 5
  • 16
  • 29

1 Answers1

0

That occurrence of _dictInit in deps/hiredis/dict.c is the first entry in the database.

Since there are two entries you should get a list like this one:

cscope result

that allows you to choose which definition to jump to.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • I set vimrc like this:`nmap g :cs find g =expand(""):copen` it would open quickfix window like you show, but it automatically selected 1st file to locate. – solomon_wzs May 16 '13 at 08:51
  • This is not the quickfix window: that's the normal output of a cscope query with multiple results and it's displayed in the command line. FYI, the screenshot was done with your mapping, using a database created with your snippets against the latest redis source. – romainl May 16 '13 at 08:57
  • I install the plugin `cscope.vim` and found that `set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-`, after I delete `g-`, it was ok. Thanks. – solomon_wzs May 16 '13 at 09:06