在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
Run Code Online (Sandbox Code Playgroud)
如何设置ag并ctrlp正确忽略这些目录?在移植到vimrc时,不确定是否需要使用不同的语法(如regex)或其他一些问题.
我没有把它放在野外的原因是我的.gitignore中忽略了node_modules,所以我使用该-U选项忽略任何vcs文件(从而允许ag搜索node_modules) - 但是这个选项似乎也绕过了wildignore.
像你一样,我使用这两种工具,但我忽略文件夹的方式是不同的
对于Ag我使用该.agignore文件,它具有相同的sintax,.gitignore就像它一样,它可以进入你的主文件夹或项目文件夹.
不知道这会解决你的问题Ctrlp,在任何情况下,它是相当快的已经是我,所以我用正常忽略的变量是这样的:
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](doc|tmp|node_modules)',
\ 'file': '\v\.(exe|so|dll)$',
\ }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2269 次 |
| 最近记录: |