我已经查看并尝试使用兴高采烈的ctags,但没有达到我想要的效果。我正在Mac上尝试在一个项目中工作,我希望排除.git、node_modules、test等目录。当我尝试像ctags -R --exclude=[.git, node_modules, test]
这样的命令时,什么也没有返回。我只需要它在我的核心目录中运行即可。有什么方法可以实现吗?
我已经查看并尝试使用兴高采烈的ctags,但没有达到我想要的效果。我正在Mac上尝试在一个项目中工作,我希望排除.git、node_modules、test等目录。当我尝试像ctags -R --exclude=[.git, node_modules, test]
这样的命令时,什么也没有返回。我只需要它在我的核心目录中运行即可。有什么方法可以实现吗?
--exclude
选项不需要文件列表。根据ctags
的手册页面,“可以指定此选项任意次数。” 因此,命令应该像这样:
ctags -R --exclude=.git --exclude=node_modules --exclude=test
ctags -R 你的目录
。或者我不明白你的意思。 - aalazzcd
命令进入该目录并运行 ctags -R
命令。 - aalazzfind -name your-files -o -path your-path > list.txt; ctags -L list.txt
- m-ric阅读 奇妙手册 应该是解决问题的第一步。
来自$ 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个目录。
@
即--exclude=@.ignorefiles
不起作用(实际上,它确实起作用,请参见我的编辑)编辑:经典的橡皮鸭解决方案...确保忽略文件没有以/
结尾的目录。 - Samaursa你可以使用花括号将逗号分隔的列表封装起来,以处理多个--exclude
选项:
ctags -R --exclude={folder1,folder2,folder3}
看起来这只适用于您发出命令的位置根目录中的文件夹。要排除嵌套的文件夹,需要单独使用--exclude
选项。
ctags -R --exclude={.git/*,.env/*,.idea/*} ./
sed "s/\///" .gitignore > .ctagsignore
ctags -R --exclude=@.ctagsignore