重新加载Vim标签文件

24

如何在 Vim 中重新加载 tags 文件?

是否需要重新启动 Vim?


不需要重新加载,vim 不会将其保存在内存中。每次查找标签时,它将执行文件的二进制搜索。 - Benoit
几天前,我不得不重新启动 Vim 才能使新的 tags 文件生效。Vim 版本:7.2 - Andrew_1510
也许在不同的子目录中有多个标签文件,并且正在重新生成错误的标签文件? - jberryman
看起来它没有存储在内存中,但我刚刚得出了相同的结论,然后意识到我拼错了对象名称(这就是为什么它找不到它的原因)! - Shane
3个回答

20
根据`:help tag-binary-search`,每次查找标签文件时都会进行二进制(或线性)搜索,因此无需重新加载文件。
                                                        *tag-binary-search*
Vim uses binary searching in the tags file to find the desired tag quickly
(when enabled at compile time |+tag_binary|).  But this only works if the
tags file was sorted on ASCII byte value.  Therefore, if no match was found,
another try is done with a linear search.  If you only want the linear search,
reset the 'tagbsearch' option.  Or better: Sort the tags file!

Note that the binary searching is disabled when not looking for a tag with a
specific name.  This happens when ignoring case and when a regular expression
is used that doesn't start with a fixed string.  Tag searching can be a lot
slower then.  The former can be avoided by case-fold sorting the tags file.
See 'tagbsearch' for details.

抱歉,但是你的报价中哪里提到了这一点? - asymmetric
我猜这是暗示(如果文件在某个时刻加载到内存中,为什么还要在标签文件中进行二进制搜索?)。 - jrdioko

4
据我所知,一旦生成了tags文件,Vim 7.3并不需要使用它。

1
我发现把tags文件加载到另一个缓冲区/标签页中会有所帮助。然后,我可以使用:e!重新加载该缓冲区,以便让vim看到我的标签更新。

这对我起作用了!(可能是因为我在打开vim之后创建了标签文件)。 - Vargas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接