18

我正在使用一个非常大的代码库,我发现选择包含哪些目录以用于 Exuberant Ctags 很有用。

--exclude选项可以很好地消除单个文件和目录名称(使用通配符),但我无法弄清楚如何让它排除包含多个目录的路径模式。

例如,我可能想排除一个目录tests,但仅在处理时thirdparty\tests(在 Windows 下)。问题是如果我只使用--exclude=tests我排除了太多目录,包括我正在积极处理的代码中的测试目录。

以下是我尝试过的一些事情:

--exclude=thirdparty\tests
--exclude=thirdparty\\tests
--exclude=*\thirdparty\tests
--exclude=*\\thirdparty\\tests
--exclude=thirdparty/tests

Ctags 默默地忽略了所有这些,正如对标签文件的检查所证明的那样。

仅当目录前面有给定的父目录时,如何才能排除该目录?

添加:

这是我的ctags --version输出:

Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jul  9 2009, 17:05:35
  Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
  Optional compiled features: +win32, +regex, +internal-sort
4

3 回答 3

16

在某些时候,定义您想要索引的文件列表可能会更容易;将该列表保存到文件中,并用于ctags -L <filename>仅对选定的几个进行索引。

这使您可以find(1)用来修剪不想索引的目录,例如:

find . -path ./Documentation -prune -o -print > indexme

将跳过所有子目录中的所有文件./Documentation

于 2011-11-19T09:56:14.283 回答
10
ack -f | ctags -L -

ack将列出给定目录中的源文件。ack -f --ruby您可以使用或将范围限制为特定语言ack -f --type=ruby。您也可以使用--ignore-dir.

用于ack --dump查看 ack 的内置文件类型。

于 2014-06-10T12:45:57.180 回答
0

ctags -R --exclude="第三方/测试/**"

使用“dir/**”修复我的情况

于 2021-06-04T05:43:25.090 回答