21

I tried to put ignored setting in .vimrc

But when I used the ctrlp to search under rails app folder

It still search the vendor folder, so it took lots of time.

But when the search was done, I couldn't search anything under the vendor

It was so strange! How to fix it.

Here is my .vimrc setting file.

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$'
  \ }

When I appended the code in the end of .vimrc

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

It worked when my first time to use the CTRLP to search under the RAILS app folder, But still NOT worked in the following times.

I guess maybe there are some settings will disable the ignored setting ?

Here are the structure of my folder

.
├── 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
newBike
  • 14,385
  • 29
  • 109
  • 192
  • 1
    I don't see `vendor` in your dir ignore list...... – Kent Jan 09 '14 at 10:46
  • Are you using a plugin that pays attention to `g:ctrlp_custom_ignore`? In plain vim, setting such a global variable will not have any effect. – benjifisher Jan 09 '14 at 13:32
  • could you give the output of `tree` or `find .` in the directory you're calling vim inside? We don't know how your folders and file setup look like, and that would be helpful for us to get an idea. Ideally, you would give us the full output here: https://asciinema.org/ – Ehtesh Choudhury Jan 09 '14 at 15:39

5 Answers5

30

If you type :help ctrlp-options and read a bit, you will find:

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.

Thus, you may need to unlet g:ctrlp_user_command (possibly set to a default command) to actually use wildignore as advised by @TomCammann. For instance, in your ~/.vimrc, add:

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

After that, you need to refresh your ctrlp cache: in Vim, press F5 in ctrlp mode, or run :CtrlPClearAllCaches, or remove the cache directory directly in your shell:

rm -r ~/.cache/ctrlp/      # On Linux
BenC
  • 8,729
  • 3
  • 49
  • 68
  • Adding that gives me ```E108: No such variable: "g:ctrlp_user_command"``` – Ian Vaughan Apr 22 '14 at 11:31
  • @IanVaughan: is your `ctrlp` plugin up-to-date? This was set to a default value in my case, but if it's not, a guard needs to be added. Check my updated answer. – BenC Apr 22 '14 at 12:08
  • 1
    Clearing the cache is important if you have already found files you want to exclude and are trying to exclude them subsequently. – Paul Aug 28 '15 at 12:02
21

part of my .vimrc file . perhaps it will help

  set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.idea/*,*/.DS_Store,*/vendor
Hassan Jamal
  • 694
  • 9
  • 11
6

You can use the wildignore vim setting which CtrlP will pick up on.

set wildignore+=*\\vendor\\**
Tom
  • 15,798
  • 4
  • 37
  • 48
  • hi your setting only worked at the first time I ran `CtrlP`, And not worked in the following times. I have no idea, it must my problems. – newBike Jan 10 '14 at 01:36
5

Check if you are using some specific search command, like:

let g:ctrlp_user_command = 'find %s -type f'        " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d'  " Windows

This kind of configuration ignores the g:ctrlp_custom_ignore option.

Joao Ferreira
  • 81
  • 1
  • 3
0

wildignore may be used by other commands, the reason of failure for g:ctrlp_custom_ignore is g:ctrlp_user_command, for example, here is mine:

if executable('rg')
    let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob ""'
endif

For this case, rg has own ignore way, just put .git to .gitignore, rg will not search any files in .gitignore.

Cui Mingda
  • 803
  • 1
  • 6
  • 15