首页 > 解决方案 > ctags 将地址标记为行号

问题描述

我正在创建一个 IDE,我希望实现跳转到定义。

我找到了完美的工具:ctags ( https://github.com/universal-ctags/ctags )

现在唯一的问题是 ctags 创建的标签文件看起来像这样:

QLineNumberArea 2point56mb.py /^class QLineNumberArea(QWidget):$/;" c

我理解格式:{tagname}Tab{tagfile}Tab{tagaddress}

所以据我了解::tagnameQLineNumberArea,tagfile:2point56mb.py 和tagaddress:/^class QLineNumberArea(QWidget):$/;" c`

tagaddress 看起来像乱码,但它是一个 vim/ex 编辑器命令,可将您带到定义。

现在从我在这个网站上读到的内容:https ://github.com/cztchoice/ctags/wiki/Tag-Format

根据Security它指出:

Specifically, these two Ex commands are allowed:

A decimal line number:

89 A search command. It is a regular expression pattern, as used by Vi, enclosed in // or ??:

/^int c;$/ ?main()?

现在问题来了:

我需要我的标签文件有一个行号,而不是搜索命令。我尝试查找 ctags 的文档(http://docs.ctags.io/en/latest/),但找不到任何可以帮助我的东西。

有谁知道如何让 ctags 将标签地址作为行号而不是搜索命令提供?

标签: ctagsuniversal-ctags

解决方案


该文档仅适用于通用 ctags 引入的更改。您正在寻找的是exuberant ctags的文档:

−−excmd=type

Determines the type of EX command used to locate tags in the source file. [Ignored in etags mode]

这也可以通过-n.


推荐阅读