为两个不同目录中的 .h 和 .c 文件生成标签时的 ctags 问题
现在我有两个目录,所有头文件 *.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 vim 中,尝试输入:
:pwd
:set Tags
验证标记文件的路径是否存在于 2 的输出中,相对于 1 的输出路径。
注意:您可以将
tags
变量设置为本地.vimrc
的一部分。更新:通常将
tags
设置为tags,../tags,../../tags
之类的模式。通过这种模式,vim 将使用它找到您的文件夹结构的第一个标签文件(同样相对于您的pwd
)。In vim, try typing:
:pwd
: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 liketags,../tags,../../tags
. With this pattern, vim will use the first tags file that it finds your folder structure (again relative to yourpwd
).转到 /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.