[Ilugc] cscope help
steve at lonetwin.net
Wed Jan 13 12:38:21 IST 2010
On 01/13/2010 11:43 AM, narendran krishnan wrote:
> I have been using cscope to search keywords like function-calls using
> vim editor. It has been very useful to me. The cscope_maps.vim was put
> in the /usr/share/vim/vim61/plugin/cscope_maps.vim in Linux RedHat 9.
> And it was working perfectly fine. Now I have shifted to a new working
> place. I am trying to put the cscope_maps.vim in the same place ie
> /usr/share/vim/vim70/plugin/cscope_maps.vim. I created the database
> by doing cscope –R. But when I open vim editor I am getting the error
> message as “E568: duplicate cscope database not added”. I tried adding
> the contents into ~/.vimrc. I am getting the same error. The line no
> that is giving error in the script is “cs add cscope.out”. I am not
> able to find out what is the problem. Can u please help on the same.
I am not quite sure I follow what you described, so, I'll just recommend what
can be considered the 'standard' way to do this:
a. Always add you personal vim plugins in your '$HOME/.vim/plugins' directory
rather than the system-wide dir (ie: /usr/share/vim...). Doing this ensures that
you don't risk losing/overwriting your plugins on an update. Also, it is easier
to move you personal config/plugins between systems.
b. I personally prefer to comment out the entire 'default' configuration that is
shipped on Red Hat systems, (ie: /etc/vimrc). On my fedora 12 system, there
appears to be a cscope specific block. This may be the case for you too, which
would explain the 'duplicate cscope database' message.
c. The cscope_maps.vim recognizes the $CSCOPE_DB variable, so, I prefer to
export this after creating/updating the cscope database.
d. Note that since cscope will maintain a reference to the file paths in the
manner that it receives them (ie: by default, when no other argument is given,
relative path starting from the current directory), if you need to also move
between directories, give cscope the complete paths, but collecting the files
using find and then using the '-i' option.
hmm, all of that was not too clear, so maybe it'll be better if I explain
through commands rather than words:
$ cp cscope_maps.vim ~/.vim/plugins/
$ rm /etc/vimrc # or just comment it all out
$ find `pwd` -type f -name "*.c" \
-o -name "*.cc" \
-o -name "*.cpp" \
-o -name "*.h" | sort > /tmp/cscope.files
$ cscope -bvq -f my_proj_db.out -i /tmp/cscope.files
# Look up man cscope for details of the options
$ export CSCOPE_DB=my_proj_db.out
$ vim my_proj.c
# Now i can move between any dir and the db references will work just fine
Obviously, I have put the find, cscope and export commands in a script that will
take a db name and has a central store for all the dbs. I can send that to you
offline if you want me to.
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
More information about the ilugc