Vim - Get All Tags Of A Buffer

时间:2018-03-25 20:47:07

标签: vim


I wanna know if anybody is aware about the possibility to get in Vim all tags for the current/specific buffer. Should mean ignoring how the tags are generated, don't matter if as a single project file or stored anywhere outside. As long as Vim could find tags for that buffer I like to get this whole "snippet" as return. So of cause it's easily possible to search for a tag and get the buffer/file plus position, but how to do this in reverse, having a buffer and getting all related tags?
Of cause I read a lot of documentation and searched a while for it, but it's seems like this direction of working with tags isn't a topic anywhere. Some suggestions by anyone? Thank you!

1 个答案:

答案 0 :(得分:2)

Vim具有tagfiles()taglist()功能。后者将提供具有标记名称,filespec和一些属性的对象列表。如果您传递与任何标记(.*)匹配的正则表达式,您将获得所有标记的(可能很大)列表。

标签不直接作用于当前缓冲区。 'tags'选项提供标记源(可以通过提到的tagfiles()查询)。该选项值可以是全局的,也可以由特定的缓冲区覆盖。

你是对的,许多与标签相关的插件都会调用ctags等。直接解析输出。我想那是因为taglist()函数在较旧的Vim版本中不存在(或者它不提供插件需要的信息)。