I moved to Fedora 9 last week, and things have been working great, except for my vim, which yelled everytime I tried opening a file:
------------------------------------------------- ego@sofia:~$ vim ~/.vimrc Error detected while processing /home/ego/.vimrc: line 10: E563: stat(./cscope.out) error: 2 Press ENTER or type command to continue -------------------------------------------------
I use vim for all my development work, and use cscope to find my way through the code. I used kvaneesh’s .vimrc script to allow me to seamlessly invoke cscope commands from.
That part of the .vimrc file looked like:
----------------------------------------------------------------------------------
if has("cscope")
cs add ./cscope.out
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" check cscope for definition of a symbol before checking ctags: set to 1
" if you want the reverse search order.
set csto=0
set grepprg=cscope\ -R\ -L\ -3
" The following maps all invoke one of the following cscope search types:
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
"
map tl :exe 'cs find g ' .expand("<cword>")<CR>
map ta :exe 'cs find t ' .expand("<cword>")<CR>
map tf :exe 'cs find c ' .expand("<cword>")<CR>
map tg :exe 'tab cs find g ' .expand("<cword>")<CR>
map gr :exe 'cs find c ' .expand("<cword>")<CR>
map tr :exe 'cs find c ' .expand("<cword>")<CR>
map st :exe 'cs find g ' .tolower(expand("<cword>"))<CR>
endif
----------------------------------------------------------------------------------
This used to work fine on Ubuntu Edgy Eft and Gutsy Gibbon.
However, this failed on Fedora9 which has Vim 7.1. So I read up the vimrc help, and found out this function called
filereadable(filename),
which will return true if the file exists and is readable.
So I changed the script to:
----------------------------------------------------------------------------------
if has("cscope")
if filereadable("./cscope.out")
cs add ./cscope.out
endif
.
.
.
endif
----------------------------------------------------------------------------------
This one too failed to work, giving another new error message:
---------------------------------------------------------------------------------- ego@sofia:~/git/linux-2.6$ vim kernel/sched.c Error detected while processing /home/ego/.vimrc: line 11: E568: duplicate cscope database not added Press ENTER or type command to continue ----------------------------------------------------------------------------------
After poking around a bit, I used one more function,
exists(filename)
and this time my .vimrc looked like:
----------------------------------------------------------------------------------
if has("cscope")
if exists("./cscope.out")
cs add ./cscope.out
endif
.
.
.
endif
----------------------------------------------------------------------------------
This one worked!
However, it fails on the older vim versions, where
filereadable()
seems to work!
Developers! They love change ![]()
PS: kvaneesh runs the same version as I do.. But he’s running it on Ubuntu 8.04. So may be this is an issue with how the distros have patched the Vim.

One Response to “Vim Scripts change in v7.1”
Thank you very much…
Tried lot of things….. but didn;t worked
if exists(”path/cscope.out”)
cs add path/cscope.out
endif
This worked.
Leave a Reply