Vim 标记列表不会动态更新
我是VIMscript的初学者。在编码时,我需要更新标记和cscope数据库,以便我可以跳转并搜索新添加的代码(函数、宏等) 我的Vim 标记列表不会动态更新,vim,ctags,cscope,Vim,Ctags,Cscope,我是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>/de
.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>
system()
使用系统
交换执行
。这有两个好处:
system
的工作方式,屏幕不会闪烁,需要重新绘制silent
而不是silent代码>-后者隐藏任何错误
normal==
如何假装用户从正常模式运行。(可以使用normal!
避免贴图)
要运行,例如,:cscope reset
或:TlistUpdate
,只需运行它们:
function! UpdateTags() abort
" ...
cscope reset
TlistUpdate
" ...
endfunction
normal==:命令
在做什么?我一眼就明白了这一点。我按照这个链接在函数中添加了普通命令:这是专门用于重新缩进的。对于冒号/Ex命令,您不需要使用normal
function! UpdateTags() abort
" ...
cscope reset
TlistUpdate
" ...
endfunction