请教高手,vim+ctags如何查找一个tag的所有引用,而不是定义。
请教高手,vim+ctags如何查找一个tag的所有引用,而不是定义。
比如我定义了一个函数,abc()
我要查找整个工程里面都有些谁引用了我的abc函数,怎么弄?
[解决办法]
加装cscope
cscope commands:
add : Add a new database (Usage: add file
[解决办法]
dir [pre-path] [flags])
find : Query for a pattern (Usage: find c
[解决办法]
d
[解决办法]
e
[解决办法]
f
[解决办法]
g
[解决办法]
i
[解决办法]
s
[解决办法]
t name)
c: Find functions calling this function
d: Find functions called by this function
e: Find this egrep pattern
f: Find this file
g: Find this definition
i: Find files #including this file
s: Find this C symbol
t: Find assignments to
help : Show this message (Usage: help)
kill : Kill a connection (Usage: kill #)
reset: Reinit all connections (Usage: reset)
show : Show connections (Usage: show)
[解决办法]
cs f t xxxxx
[解决办法]
每次打开文件都要执行:cs add xxx,
你可以把那个写到配置文件里去,我是这么写的,
顺便把cs find type xxx都绑定到快捷键了.
if has("cscope")
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>d :cs find d <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-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>i :cs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
if filereadable("cscope.out")
cs add cscope.out
"这里可以写绝对路径
endif
endif