ag
在命令行上使用时,如下所示:
$> ag . --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""
我能够避免在我的节点服务中搜索超过一层的任何 node_modules 目录,这是所需的行为。
但是,当我在 vimrc 中使用以下内容时,不会忽略超过一级深度的 node_modules 目录:
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""'
endif
如何设置ag
并ctrlp
正确忽略这些目录?不确定在移植到 vimrc 时是否需要使用不同的语法(如正则表达式)或其他一些问题。
我没有把它放在 wildignore 中的原因是 node_modules 在我的 .gitignore 中被忽略了,所以我使用-U
忽略任何 vcs 文件的选项(从而允许ag
搜索 node_modules)——但这个选项似乎也绕过了野蛮的。