8

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'
rb-
  • 2,315
  • 29
  • 41

1 Answers1

11

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',
  \ }
h7r
  • 4,944
  • 2
  • 28
  • 31
  • I've seen that in the README.md on Github, but when I put it in my .vimrc I get an 'invalid expression' error. – rb- Jan 25 '15 at 17:25
  • Please edit your question to provide this information for future reference. – h7r Jan 25 '15 at 17:28
  • Actually I spoke too soon on that. So the problem I have now is that not all directories I want to ignore start with a dot. – rb- Jan 25 '15 at 17:28
  • You don't need to have dots on all directories that you mention on that field. This is a regular expression just like any other. You can have something like `\vfoo_without_dot\|\.(git|bar)`, for example – h7r Jan 25 '15 at 17:29
  • 8
    Simple enough. This does what I wanted. `'dir': '\v[\/](\.git|node_modules|\.sass-cache|bower_components|build)$'` Thanks! – rb- Jan 25 '15 at 17:31
  • could you please explain the syntax '\v[\/]' ? – Hui Wang Jul 11 '15 at 06:35
  • me too, waiting explain about syntax '\v[\/]' – deemstone Dec 24 '15 at 03:48
  • 2
    @HuiWang, @deemstone this is vimscript's "very magic" regexp modifyier, which changes the behaviour of some characters in the context of a regular expression (usually allowing it to be written in simplified form) See http://vimdoc.sourceforge.net/htmldoc/pattern.html#/magic About `[\/]`, means nothing special: matches any of '\' or '/' (remember directory separator on Windows). – h7r Dec 24 '15 at 14:52
  • https://superuser.com/questions/649714/can-i-get-the-vim-ctrlp-plugin-to-ignore-a-specific-folder-in-one-project#660318 – Fabrizio Bertoglio Feb 03 '19 at 12:20