vim - ctrlp 仍然搜索被忽略的目录

标签 vim ctrlp

我尝试将忽略的设置放入 .vimrc

但是当我使用ctrlp在rails应用程序文件夹下搜索时

它仍然搜索vendor文件夹,因此花费了大量时间。

但是当搜索完成后,我无法搜索到vendor下的任何内容

太奇怪了!如何修复它。

这是我的 .vimrc 设置文件。

http://d.pr/i/yMtK http://d.pr/i/Hy4u

" Sane Ignore For ctrlp
let g:ctrlp_custom_ignore = {
  \ 'dir':  '\.git$|vendor\|\.hg$\|\.svn$\|\.yardoc\|public\/images\|public\/system\|data\|log\|tmp$',
  \ 'file': '\.exe$\|\.so$\|\.dat$'
  \ }

当我将代码附加到 .vimrc 末尾时

217 let g:NERDTreeIgnore=['\~$', 'vendor']
218 set wildignore+=*\\vendor\\**

当我第一次使用 CTRLP 在 RAILS 应用程序文件夹下搜索时,它起作用了, 但在接下来的时间里仍然工作。

我猜也许有一些设置会禁用被忽略的设置?

这是我的文件夹的结构

.
├── Gemfile
├── Gemfile.lock
├── README.rdoc
├── Rakefile
├── app
│   ├── assets
│   ├── controllers
│   ├── helpers
│   ├── mailers
│   ├── models
│   ├── uploaders
│   ├── views
│   └── workers
├── auto.sh
├── config
│   ├── application.rb
│   ├── application.yml
│   ├── boot.rb
│   ├── database.yml
│   ├── environment.rb
│   ├── environments
│   ├── initializers
│   ├── locales
│   ├── macbookair_whenever_schedule.rb
│   ├── menu_navigation.rb
│   ├── navigation.rb
│   ├── resque.god
│   ├── resque_schedule.yml
│   ├── routes.rb
│   ├── schedule.rb -> ubuntu_whenever_schedule.rb
│   ├── tinymce.yml
│   └── ubuntu_whenever_schedule.rb
├── config.ru
├── db
│   ├── development.sqlite3
│   ├── migrate
│   ├── migrate_should_be_skip
│   ├── production.sqlite3
│   ├── schema.rb
│   └── seeds.rb
├── doc
│   └── README_FOR_APP
├── lib
│   ├── assets
│   ├── auto_tools
│   ├── tasks
│   └── url_automation_module.rb
├── log
│   ├── apalog
│   ├── development.log
│   ├── passenger.80.log
│   ├── production.log
│   └── prodution.log
├── output_name
├── public
│   ├── 404.html
│   ├── 422.html
│   ├── 500.html
│   ├── exports
│   ├── favicon.ico
│   ├── results.zip
│   ├── robots.txt
│   ├── sandbox
│   └── uploads
├── script
│   ├── delayed_job
│   └── rails
├── test
│   ├── fixtures
│   ├── functional
│   ├── integration
│   ├── performance
│   ├── test_helper.rb
│   └── unit
├── test.sh
├── tmp
│   ├── cache
│   ├── pids
│   ├── restart.txt
│   ├── sessions
│   └── sockets
├── tmplog
└── vendor
    └── bundle

最佳答案

如果您输入 :help ctrlp-options 并阅读一下,您会发现:

Note #1: by default, wildignore and g:ctrlp_custom_ignore only apply when globpath() is used to scan for files, thus these options do not apply when a command defined with g:ctrlp_user_command is being used.

因此,您可能需要unlet g:ctrlp_user_command(可能设置为默认命令)才能按照@TomCammann 的建议实际使用wildignore。例如,在您的 ~/.vimrc 中,添加:

if exists("g:ctrlp_user_command")
  unlet g:ctrlp_user_command
endif
set wildignore+=*\\vendor\\**

之后,您需要刷新 ctrlp 缓存:在 Vim 中,在 ctrlp 模式下按 F5,或运行 : CtrlPClearAllCaches,或直接在 shell 中删除缓存目录:

rm -r ~/.cache/ctrlp/      # On Linux

关于vim - ctrlp 仍然搜索被忽略的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21017857/

相关文章:

vim - ctrlp : open selected file in the left vertical split

git - CtrlP:忽略 git repo 子目录中的文件

vim - 如何自定义 CtrlP 提示符内的映射 - VIM

在vim中编辑的python文件移动到intellij会遇到缩进不一致错误

linux - 如何使用 vim 命令行从 vim 编辑器中复制所有文本?

vim - 在 Vim 中换行?

search - 如何在VIM中使用通配符进行搜索

vim - 如何搜索/替换特殊字符?

vim - 忽略 ctrlp.vim 中的自定义目录