如何在vim中自动更新标签文件? [英] How to automatically update tag file in vim?

查看:102
本文介绍了如何在vim中自动更新标签文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 vim C++ 标记文件使用 Ctrl-] 进行导航.问题是每当某些文件被修改时,链接就不再有效,我必须重新运行 ctags 并更新标记文件.我们的代码库很大,生成标签文件需要很长时间.

I use vim C++ tag file for navigation using Ctrl-]. The problem is whenever some file gets modified, the links are no longer valid and I have to re-run ctags and update the tag file. Our code base is huge and it takes quite a while for generating tag file.

有什么工具可以在后台定期更新标签文件?我可以配置 VIM 来做同样的事情吗?

Is there any tool which periodically updates the tag file in background? Can I configure VIM to do the same?

我在 Windows 下使用 gvim.

I use gvim under Windows.

推荐答案

除了 Blixtor 的回答之外,您还需要仔细考虑脚本的设计.我建议隔离设计,以便自动命令使用 Windows启动"命令或类似命令在后台运行外部脚本:从而防止 Vim 在生成标记文件时无响应.

Further to Blixtor's answer, you'll need to think a little carefully about the design of the script. I'd recommend segregating the design such that the autocommand uses the Windows "start" command or similar to run an external script in the background: thereby preventing Vim from being unresponsive while the tag file is generated.

然后该脚本可以使用不同的文件名(即不是标签":ctags -R -o newtags .)生成标签文件,并且当 ctags 完成时,删除 tags 并将 newtags 重命名为 tags.这将防止标记文件在生成完成后在 Vim 中不可用.

That script could then generate the tag file using a different file name (i.e. not "tags": ctags -R -o newtags .) and, when ctags is complete, delete tags and rename newtags to tags. This will prevent the tag file from being unavailable in Vim while the generation is done.

这篇关于如何在vim中自动更新标签文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆