Wednesday, September 5, 2007

cscope + vim


Using cscope with vim will allow you to browse code seamlessly. Refer to the following link for setting up the mapping between cscope and vim http://cscope.sourceforge.net/cscope_vim_tutorial.html

Download the mapping file here http://cscope.sourceforge.net/cscope_maps.vim

Go to the top-level source directory and type cscope -R

I faced "duplicate database found" error and so had to comment out following lines from cscope_maps.vim

" add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif

Also remember to open the source file from the same source level directory where you typed cscope -R else mapping won't work.

For example:
Consider directory /src/linux/foo/bar
If you created cross-reference DB in /src and want to open file a.c in /src/linux/foo/bar then cd into /src and then open file using
vim linux/foo/bar/a.c

1 comment:

DipTea said...

i wish someone would write a blog on cscope + vim + windows also !! maybe someday i will ;)