我是VIMscript的初学者。在编写代码时,我需要更新标记和cscope数据库,以便跳转和搜索新添加的代码(函数、宏等)。
我的.vimrc文件有以下代码:
function UpdateTags()
silent! execute (":!rm -rf tags cscope.files cscope.out")
silent! execute (":!ctags -R . *.c *.h *.hpp *.cpp --tag-relative=yes ./ 2>/dev/null")
silent! execute (":!cscope -b -R") | redraw!
normal == :cs reset<CR><CR>
normal == :TlistUpdate<CR>
endfunction
nnoremap <silent> <C-k> :call UpdateTags()<CR>我看到标签和cscope.out文件被更新了。然而,我无法解决这几件事:
,
,
:TlistUpdate命令,则会看到新的标记.。
下面的代码正在工作:
function UpdateTags()
call system ("rm -rf tags cscope.files cscope.out")
call system ("ctags -R . *.c *.h *.hpp *.cpp --tag-relative=yes ./ 2>/dev/null")
call system ("cscope -b -R")
silent cscope reset
TlistUpdate
endfunction发布于 2019-10-15 15:09:10
sytem()
将execute与system交换。这有两个好处:
system如何工作silent而不是silent!-the,后者隐藏了的任何错误
使用Ex (冒号)命令作为命令
normal ==您如何假装用户从正常模式运行==。(您可以使用normal!避免映射。)
要运行(例如,:cscope reset或:TlistUpdate ),只需运行它们:
function! UpdateTags() abort
" ...
cscope reset
TlistUpdate
" ...
endfunctionhttps://stackoverflow.com/questions/58343617
复制相似问题