Created
March 16, 2013 12:12
-
-
Save soarpenguin/5176135 to your computer and use it in GitHub Desktop.
解决vim/gvim中使用tags或cscope.out文件更新问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
添加如下代码到.vimrc文件中 | |
function UpdateCtags() | |
let curdir=getcwd() | |
while !filereadable("./tags") | |
cd .. | |
if getcwd() == "/" | |
break | |
endif | |
endwhile | |
if filewritable("./tags") | |
:!ctags -R | |
endif | |
execute ":cd " . curdir | |
endfunction | |
function UpdateCStags() | |
let curdir=getcwd() | |
while !filereadable("./cscope.out") | |
cd .. | |
if getcwd() == "/" | |
break | |
endif | |
endwhile | |
if filewritable("./cscope.out") | |
:!cscope -Rbq | |
execute ":cscope kill 0" | |
execute ":cscope add cscope.out" | |
endif | |
execute ":cd " . curdir | |
endfunction | |
nmap <F8> :call UpdateCtags()<CR> | |
nmap <F9> :call UpdateCStags()<CR> | |
这样就可以在更新源代码文件后,随时使用<F8>及<F9>更新tags及cscope.out文件, | |
不必关闭编辑文件,执行ctags -R/cscope -Rbq及重新打开文件。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment