为标签和围兜项目创建乳胶标签文件

发布于 2024-12-15 12:09:13 字数 553 浏览 2 评论 0原文

我正在使用 ctags 创建一个在 Vim 中使用的标签文件,以便我可以跳转到标签和引用的定义。但是,我有两个问题:

  1. ctags 在标签文件中包含 \ref ,因此当我在 \ref 标签上点击跳转时,我不一定跳转到定义标签,但最终可能会出现对该标签的另一个引用。
  2. 我希望能够从 \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:

  1. 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.
  2. I'd like to be able to jump to the corresponding entry in a .bib file from a \cite command, but ctags doesn't generate entries for that (I'm using ctags *.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 技术交流群。

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

发布评论

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

评论(1

想挽留 2024-12-22 12:09:13

我意识到我没有使用exuberant ctags,而是另一个ctags程序,所以中的内容~/.ctags 从未使用过。

我还设法在 ~/.ctags 中添加另一个条目作为围兜条目:

--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/

--langdef=bib
--langmap=bib:.bib
--regex-bib=/^@[A-Za-z]+\{([^,]*)/\1/b,bib/

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:

--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/

--langdef=bib
--langmap=bib:.bib
--regex-bib=/^@[A-Za-z]+\{([^,]*)/\1/b,bib/

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/.

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