我有一个简单的c++文件,就像这样:
class SomeClass
{
void SomeMethod() {};
};
class AnotherClass
{
void SomeMethod() {};
};
如果我使用
ctags -R *
生成ctags文件,我会得到以下结果:AnotherClass main.cpp /^ class AnotherClass$/;" c file:
SomeClass main.cpp /^ class SomeClass$/;" c file:
SomeMethod main.cpp /^ void SomeMethod() {};$/;" f class:AnotherClass typeref:typename:void file:
SomeMethod main.cpp /^ void SomeMethod() {};$/;" f class:SomeClass typeref:typename:void file:
正如您所看到的,SomeMethod
的定义条目与 vim 中的 tf
和 tn
中的相同,始终显示文件中的第一个定义。
我还可以使用 ctags --fields=+n *
添加行号,结果如下:
...
AnotherClass main.cpp /^ class AnotherClass$/;" c line:6 file:
SomeClass main.cpp /^ class SomeClass$/;" c line:1 file:
SomeMethod main.cpp /^ void SomeMethod() {};$/;" f line:3 class:SomeClass typeref:typename:void file:
SomeMethod main.cpp /^ void SomeMethod() {};$/;" f line:8 class:AnotherClass typeref:typename:void file:
但是,如果我使用 ta SomeMethod
和 tn
,vim 也会始终跳转到第一个 SomeMethod
的定义。
我在这个版本中使用了 ctags:
Universal Ctags 0.0.0(2614dbe1),版权所有 (C) 2015 Universal Ctags Team Universal Ctags 源自 Exuberant Ctags。 Exuberant Ctags 5.8,版权所有 (C) 1996-2009 Darren Hiebert 编译时间:Sep 5 2019, 13:10:38 URL: https://ctags.io/ 可选的编译特性: +wildcards, +regex, +iconv, +option-directory, +xpath, +yaml, +packcc
而 vim 是:
VIM - Vi IMproved 8.1 Patch 1-1713