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

per*_*ai1 45 vim ctags exuberant-ctags

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

小智 65

--exclude选项不期望文件列表.根据ctags的手册页,"可以根据需要多次指定此选项." 所以,就像这样:

ctags -R --exclude=.git --exclude=node_modules --exclude=test

  • @pertrai1 首先列出您想要标记的文件列表,然后仅在此列表上运行 ctags:`find -name your-files -o -path your-path > list.txt; ctags -L 列表.txt` (2认同)

rom*_*inl 36

[R EAD 牛逼˚F antastic 中号 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.
Run Code Online (Sandbox Code Playgroud)

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

$ ctags -R --exclude=dir1 --exclude=dir2 --exclude=dir3 .
Run Code Online (Sandbox Code Playgroud)

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

$ ctags -R --exclude=@.ctagsignore .
Run Code Online (Sandbox Code Playgroud)

以下内容.ctagsignore:

dir1
dir2
dir3
Run Code Online (Sandbox Code Playgroud)

这样就可以在没有那么多打字的情况下排除这3个目录.

  • 嗯.作为一个方便的答案,我猜想这会让我成为一个坏人,因为我应该有RTFM而不是来这里! (4认同)
  • 我最喜欢的RTFM方式是谷歌搜索,并希望有人在SO上为我解释TFM.谢谢! (4认同)
  • 感谢你的回答。恕我直言,事情已经发生了变化,现在在线快速搜索特定解决方案然后 RTFM(如果您没有找到)会更有效。 (2认同)

voo*_*oGQ 13

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

ctags -R --exclude={folder1,folder2,folder3}
Run Code Online (Sandbox Code Playgroud)

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

  • shell 大括号扩展的巧妙使用! (2认同)