首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Taglist不会被动态更新。

Taglist不会被动态更新。
EN

Stack Overflow用户
提问于 2019-10-11 14:41:32
回答 1查看 109关注 0票数 0

我是VIMscript的初学者。在编写代码时,我需要更新标记和cscope数据库,以便跳转和搜索新添加的代码(函数、宏等)。

我的.vimrc文件有以下代码:

代码语言:javascript
复制
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文件被更新了。然而,我无法解决这几件事:

  • ,屏幕闪烁两次(我只在函数中重画了一次),

  • ,taglist没有更新。如果再次手动执行:TlistUpdate命令,则会看到新的标记.

下面的代码正在工作:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-15 15:09:10

sytem()

executesystem交换。这有两个好处:

  1. 屏幕不闪烁,需要重绘,因为system如何工作
  2. ,您应该能够使用silent而不是silent!-the,后者隐藏了

的任何错误

使用Ex (冒号)命令作为命令

normal ==您如何假装用户从正常模式运行==。(您可以使用normal!避免映射。)

要运行(例如,:cscope reset:TlistUpdate ),只需运行它们:

代码语言:javascript
复制
function! UpdateTags() abort
  " ...
  cscope reset
  TlistUpdate
  " ...
endfunction
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58343617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档