Vim:设置 ctags 有困难.子目录中的源在项目根目录中看不到标签文件 [英] Vim: Difficulty setting up ctags. Source in subdirectories don't see tags file in project root

查看:32
本文介绍了Vim:设置 ctags 有困难.子目录中的源在项目根目录中看不到标签文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天试图在 Vim 上使用(旺盛的)ctags 进行设置,但很难让它正常工作.我在命令行上使用以下命令生成我的 ctags 文件:

I'm trying to get setup with (exuberant) ctags on Vim today and am having difficulty getting it to work properly. I generate my ctags file on the command line with with:

cd myproj
ctags -R

这会将标签文件放在 myproj 根目录中.但是,当我处理驻留在 root 中的源代码时,Vim 似乎只从这个标签文件中读取.当我导航到更深的目录时,如果我尝试使用 <C-]> 跳转到一个标签,我得到:

This puts the tags file in myproj root. However, Vim only seems to read from this tags file when I'm working on source that reside in root. As I navigate to deeper directories, if I try to jump to a tag using <C-]>, I get:

E433: No tags file
E426: tag not found: MyClassName

我已经验证 MyClassName 在标签文件中确实有一个标签,只是 Vim 没有看到它.有人可以解释一下如何配置 Vim 以引用根的标签文件吗?

I've verified that MyClassName does have a tag in the tags file, it's just that Vim doesn't see it. Can someone please explain how to configure Vim to reference the root's tags file?

谢谢.

推荐答案

add this to .vimrc file set tags=tags;/

add this to .vimrc file set tags=tags;/

这将检查当前文件夹中的标签文件,并一直向上移动一个目录到根文件夹.

This will check the current folder for tags file and keep going one directory up all the way to the root folder.

因此,您可以在项目的任何子文件夹中找到标签文件.

So you can be in any sub-folder in your project and it'll be able to find the tags files.

这篇关于Vim:设置 ctags 有困难.子目录中的源在项目根目录中看不到标签文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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