use cscope in vim

1 . Download vim plugin and put it into ~/.vim/plugin

      wget http://cscope.sourceforge.net/cscope_maps.vim


2 . Generate cscope.files

     find /home/sda/code/qemu-kvm/ -name '*.[ch]' -print > cscope.file


3 .  Generate cscope database( it is cscope.out)

      cscope -bq (if kernal source code use -bqk)


4 . reset terminal

      open vim

      :cs add cscope.out

5 . :cs help


6 . use ctrl + ]  and (c/d/e/f/g) etc for using easily


7. use ctrl + t ,go back last position.


also can use cscope -Rbq


use cscope in vim_第1张图片


8 use cscope  to read python code.

$ find . -name "*.py" | cscope -Rbq -i -
(注意最后有个 - 号)


修改 /etc/vim/vimrc 文件,追加

" for cscope
if has("cscope") && filereadable("/usr/bin/cscope")
    set csprg=/usr/bin/cscope
    set csto=0
    set cst
    set nocsverb
" add any database in current directory
    if filereadable("cscope.out")
        cs add $PWD/cscope.out
" else add database pointed to by environment
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif
    set csverb
endif

nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>




你可能感兴趣的:(vim,database,download,Terminal)