为两个不同目录中的 .h 和 .c 文件生成标签时的 ctags 问题

发布于 2024-08-13 06:04:43 字数 465 浏览 7 评论 0原文

现在我有两个目录,所有头文件 *.h 都包含在目录 /inc 中,而所有 c 文件 *.c 都存储在 /src 目录中。

目录就像这样,(/project 是上一级目录):

/project-- |----/inc
           |----/src

我想使用 ctrl+] 在源文件(如 example.c)中定位一个参数或一个函数的定义。如何生成这些标签?

我的方法是:

(1) cd to the /project directory

(2) ctags inc/*.h src/*.c

然后在那里生成一个标签文件,但是,当我打开示例文件并使用“Ctrl+]”时,它无法引导我找到它的定义。为什么???

我需要在/src下生成标签文件吗???

有什么帮助吗?非常感谢!

Now I have two directory, all of header files *.h are included in directory /inc, while all of c file *.c are stored in /src directory.

The directory just like this, (/project is a up level directory):

/project-- |----/inc
           |----/src

I want to use ctrl+] to locate definition of one parameter or one function in a source file like example.c. How to generate those tags?

My method is:

(1) cd to the /project directory

(2) ctags inc/*.h src/*.c

Then a tags file is generated there, however, when I open a example file and using "Ctrl+]", it cannot lead me to its definition. Why???

Do I need to generate a tags file under /src???

Any help? Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不咬妳我踢妳 2024-08-20 06:04:43

在 vim 中,尝试输入:

  1. :pwd
  2. :set Tags

验证标记文件的路径是否存在于 2 的输出中,相对于 1 的输出路径。

注意:您可以将 tags 变量设置为本地 .vimrc 的一部分。

更新:通常将 tags 设置为 tags,../tags,../../tags 之类的模式。通过这种模式,vim 将使用它找到您的文件夹结构的第一个标签文件(同样相对于您的 pwd)。

In vim, try typing:

  1. :pwd
  2. :set tags

Verify that the path to your tagfile is present in output of 2, relative to the path that is the output of 1.

NOTE: You can set the tags variable as part of your local .vimrc.

UPDATE: It is common to set tags to a pattern like tags,../tags,../../tags. With this pattern, vim will use the first tags file that it finds your folder structure (again relative to your pwd).

秋风の叶未落 2024-08-20 06:04:43

转到 /project,然后使用命令“ctags -R”。在 .vimrc 中,输入命令“set Tags=/project/tags”。退出vim,再次进入。标签现在应该可以工作了。

Go to /project, and use the command "ctags -R ." In your .vimrc, put the command "set tags=/project/tags". Exit vim and enter it again. Tags should now work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文