vim+cscope

1
2
apt install vim
apt install cscope

将以下脚本保存为~/.vimrc,注意要用dos2unix转换一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	if has("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 cscope.out
		" else add database pointed to by environment
		elseif $CSCOPE_DB != ""
		    cs add $CSCOPE_DB
		endif
		set csverb
	endif
 
	nmap <C-[>s :scs find s <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>g :scs find g <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>c :scs find c <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>t :scs find t <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>e :scs find e <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
	nmap <C-[>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
	nmap <C-[>d :scs find d <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>a :scs find a <C-R>=expand("<cword>")<CR><CR>

每次源码更新时,在源码根目录执行

1
2
3
#find . -type f | cat > cscope.files
#find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files
cscope -bqR