多个项目的 VIM 中标签的路径
我最近开始在我的项目中使用 ctags。我目前有以下设置:
root/tags [contains all non-static tags]
root/foo/tags [contains static tags for the foo directory]
root/bar/tags [static]
root/something/else/tags [etc.]
...
我可以设置tags=./tags,tags,/path/to/root/tags
并且一切正常。
但是,我的问题是我同时处理多个项目,因此我有,例如 /path/to/root1
、/path/to/root2
和/path/to/root3
一次性全部完成。我不想每次打开文件时都手动设置标签;有什么方法可以根据我正在编辑的文件将标签添加到 /path/to/rootX
吗? (即,如果我正在编辑 /path/to/root3/foo/xc
,请使用 root3/tags
中的标签?
就我而言,我的所有项目共享一个通用的父目录;我真正想要的是:
set tags=./tags,tags,substitute("%:p:h", "\(^\/path\/to\/.*/\).*$", "\1", "")
但我似乎无法获得正确的 vimfu 来使其工作
编辑:我刚刚意识到这不起作用;相反,我想将我的主 ctags 文件存储在 ~/ctags/root*/tags
中,其中 的子目录之间存在 1:1 映射>~/ctags/
和 /path/to/
[对于那些可能想知道的人来说,这些都不是 ClearCase UCM 动态视图; /view/XXX/vobs/
也不可写]
I've recently started using ctags on my projects. I currently have the following setup:
root/tags [contains all non-static tags]
root/foo/tags [contains static tags for the foo directory]
root/bar/tags [static]
root/something/else/tags [etc.]
...
I can set tags=./tags,tags,/path/to/root/tags
and everything works perfectly.
However, my problem is that I work on several projects at once, so I have, for example, /path/to/root1
, /path/to/root2
, and /path/to/root3
all at once. I'd rather not manually set the tags each time I open a file; is there any way I can have tags to to the /path/to/rootX
based on the file I'm editting? (i.e., if I'm editing /path/to/root3/foo/x.c
, use the tags in root3/tags
?
In my case, all of my projects share a common parent directory; what I really want is something like:
set tags=./tags,tags,substitute("%:p:h", "\(^\/path\/to\/.*/\).*$", "\1", "")
but I can't seem to get the right vimfu to make it work.
EDIT: I just realized that this won't work; I can't actually write to root*
. Instead, I'd like to store my main ctags file in ~/ctags/root*/tags
, where there's a 1:1 mapping between the subdirectories of ~/ctags/
and /path/to/
[For those who may be wondering, these are ClearCase UCM dynamic views; neither /view/XXX/
nor /view/XXX/vobs/
is writable]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要的是:
尝试:
:set
命令中没有扩展。另外,“%:p:h”不会自动扩展,因此请使用expand()
。看:If what you want is:
Try:
There's no expansion in a
:set
command. Also, "%:p:h" won't be expanded automatically, so useexpand()
. See: