为标签和围兜项目创建乳胶标签文件
我正在使用 ctags
创建一个在 Vim 中使用的标签文件,以便我可以跳转到标签和引用的定义。但是,我有两个问题:
- ctags 在标签文件中包含
\ref
,因此当我在\ref
标签上点击跳转时,我不一定跳转到定义标签,但最终可能会出现对该标签的另一个引用。 - 我希望能够从
\cite
命令跳转到 .bib 文件中的相应条目,但ctags
不会为此生成条目(我' m 使用ctags *.tex *.bib
)。
我想重新定义 ctags
对 tex 文件的定义,以便我可以删除 \ref
条目,但这不起作用。
我的 ~/.ctags 文件:
--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
I'm using ctags
to create a tags file for use in Vim, so that I can jump to definitions of labels and citations. However, I have two problems:
- ctags includes
\ref
in the tags file, so when I hit jump on a\ref
label, I don't necessarily jump to the definition of the label, but might end up on another reference to that label. - I'd like to be able to jump to the corresponding entry in a .bib file from a
\cite
command, butctags
doesn't generate entries for that (I'm usingctags *.tex *.bib
).
I wanted to redefine ctags
's definition for tex files, so that I could remove \ref
entries, but that didn't work.
My ~/.ctags file:
--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到我没有使用exuberant ctags,而是另一个ctags程序,所以
中的内容~/.ctags
从未使用过。我还设法在
~/.ctags
中添加另一个条目作为围兜条目:ctags *.tex *.bib
现在可以按照我想要的方式工作。您可以将正则表达式放入在线正则表达式解释器中以了解它在做什么,例如 https://regexr.com/。
I realized that I didn't use exuberant ctags, but another ctags program, so the content in
~/.ctags
was never used.I also managed to add another entry in
~/.ctags
for bib entries:ctags *.tex *.bib
works now as I want it.You can put a regex into an online regex explainer to understand what it is doing, like https://regexr.com/.