Search code examples
vimctrlp

Ignore .git directory in ctrlp.vim


In my .vimrc I have some custom ingores for ctrlp.vim. There are a few directories I want to ignore that start with a dot: .git is a good example. By having .git in the ignores, I also ignore individual files like git.sh. I only want to ignore .git. What am I doing wrong?

let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|bower_components\|.sass-cache\|.git\|build'

Solution

  • You need to specify that .git is specifically a directory ignore. From the documentation's example: https://github.com/kien/ctrlp.vim

    let g:ctrlp_custom_ignore = {
      \ 'dir':  '\v[\/]\.(git|hg|svn)$',
      \ 'file': '\v\.(exe|so|dll)$',
      \ 'link': 'some_bad_symbolic_links',
      \ }