在命令行上使用ag
时,例如:
$> ag . --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""
我可以避免搜索我的node服务中超过一层深的任何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)--但这个选项似乎也会绕过wildignore。
--ignore
部分,因为有.agignore
。我删除了-U
,以便 ag 仍然使用.gitignore
。我注意到 ag 默认忽略隐藏文件。 - tim-phillips