I use cscope with vim. When doing large edits for several files, cscope will report old line numbers for changed files. How can I rebuild cscope db from vim without losing
- opened tabs/windowses in vim
- connection with cscope engine
Thanks
I use cscope with vim. When doing large edits for several files, cscope will report old line numbers for changed files. How can I rebuild cscope db from vim without losing
Thanks
First, you need to update cscope database.
:!cscope -Rbq
Then, reinit the database from vim.
:cs reset
cscope.out
, cscope creates another one ncscope.out
. How to replace the old database? I am using a Windows cscope port. –
Bursary Building on a previous answer, add this to your .vimrc:
map <F5> :!cscope -Rb<CR>:cs reset<CR><CR>
Then use F5 within vim to do the refresh.
-b = Build cross-reference only. -R = Recurse subdirectories during search for source files.
cscope_dynamic does all you ask, and even more:
It uses two databases:
Edit: Feb17: Removed old answer as cscope_dynamic does all these out of the box.
I use a script that keeps building my indexes in the background:
" We need to setup the function that reset cscope.
"You could define this in your vimrc instead.
vim --servername GVIM --remote-send ":function! ResetCscope()<CR>cscope reset<CR>endfunction<CR>"
while true ; do
echo building...
ctags -R
cscope -Rbk
vim --servername VIM --remote-expr "ResetCscope()"
echo done. sleeping.
sleep 1m
done
(It's actually a lot more complicated than that.)
The vim call should reload the cscope database in vim if you started it with vim --servername VIM
. (I use a background command to run cscope queries, so I'm not sure about this. The command launches cscope independently and doesn't use Vim's connection.)
Tried this recently in gVim 8.0 on Windows, but even after the cs reset, vim was locking cscope.out so cs could not regenerate cscope.out with vim open.
In this case, I added the following additional mapping (F12 in e.g) which kills the current cscope connection so cscope can regenerate the cscope.out with F11, without having to close the vim. Hope this helps some one.
map <F11> :!cscope -Rbq<CR><ESC>:cs add cscope.out<CR><CR>
map <F12> :cs kill cscope.out<CR><CR>
© 2022 - 2024 — McMap. All rights reserved.