如何使用Exuberant ctags排除多个目录?

时间:2014-09-13 03:54:17

标签: vim ctags exuberant-ctags

我已经看过并试图使用旺盛的ctags而没有运气我想做什么。我在一个mac上试图在一个项目中工作,我想要排除诸如.git,node_modules,test等目录。当我尝试类似ctags -R --exclude=[.git, node_modules, test]之类的东西时,我得不到任何回报。我真的只需要在我的核心目录中运行它。关于如何实现这一目标的任何想法?

5 个答案:

答案 0 :(得分:53)

--exclude选项不期望文件列表。根据{{​​1}}的手册页,"可以根据需要多次指定此选项。"所以,它是这样的:

ctags

答案 1 :(得分:32)

R ead T F antastic M anual 总是是任何解决问题的尝试的第一步。

来自$ man ctags

--exclude=[pattern]
  Add  pattern to a list of excluded files and directories. This option may
  be specified as many times as desired. For each file name  considered  by
  both the complete path (e.g. some/path/base.ext) and the base name  (e.g.
  base.ext)  of  the  file, thus allowing patterns which match a given file
  name irrespective of its path, or match only a specific path.  If  appro-
  priate  support is available from the runtime library of your C compiler,
  then pattern may contain the usual shell wildcards (not  regular  expres-
  sions)  common  on Unix (be sure to quote the option parameter to protect
  the wildcards from being expanded by the shell  before  being  passed  to
  ctags;  also be aware that wildcards can match the slash character, '/').
  You can determine if shell wildcards are available on  your  platform  by
  examining  the output of the --version option, which will include "+wild-
  cards" in the  compiled  feature  list;  otherwise,  pattern  is  matched
  against file names using a simple textual comparison.

  If  pattern begins with the character '@', then the rest of the string is
  interpreted as a file name from which to read exclusion patterns, one per
  line.  If  pattern  is  empty,  the list of excluded patterns is cleared.
  Note that at program startup, the default exclude list contains "EIFGEN",
  "SCCS",  "RCS", and "CVS", which are names of directories for which it is
  generally not desirable to descend while processing the --recurse option.

从你得到的两个第一句话开始:

$ ctags -R --exclude=dir1 --exclude=dir2 --exclude=dir3 .

这可能有点冗长,但是别名和映射等等是什么。作为替代方案,您可以从第二段获得:

$ ctags -R --exclude=@.ctagsignore .

.ctagsignore中的以下内容:

dir1
dir2
dir3

可以在没有那么多输入的情况下排除这3个目录。

答案 2 :(得分:7)

您可以使用花括号封装逗号分隔列表,以使用一个--exclude选项处理倍数:

ctags -R --exclude={folder1,folder2,folder3}

这似乎仅适用于您发出命令的根目录中的文件夹。排除嵌套文件夹需要单独的--exclude选项。

答案 3 :(得分:2)

其他答案很明确,我认为一个小例子可能会有所帮助:

您应该添加星号类Unix样式以排除整个目录。

ctags -R --exclude={.git/*,.env/*,.idea/*} ./

答案 4 :(得分:-1)

<块引用>

我真的只需要让它在我的核心目录中运行。

只需删除 -R(递归)标志!!!

相关问题