Ignore .git directory in ctrlp.vim
Asked Answered
G

1

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'
Gal answered 25/1, 2015 at 17:15 Comment(0)
F
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',
  \ }
Fenella answered 25/1, 2015 at 17:19 Comment(9)
I've seen that in the README.md on Github, but when I put it in my .vimrc I get an 'invalid expression' error.Gal
Please edit your question to provide this information for future reference.Fenella
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.Gal
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 exampleFenella
Simple enough. This does what I wanted. 'dir': '\v[\/](\.git|node_modules|\.sass-cache|bower_components|build)$' Thanks!Gal
could you please explain the syntax '\v[\/]' ?Instantly
me too, waiting explain about syntax '\v[\/]'Wingback
@HuiWang, @Wingback 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 vimdoc.sourceforge.net/htmldoc/pattern.html#/magic About [\/], means nothing special: matches any of '\' or '/' (remember directory separator on Windows).Fenella
superuser.com/questions/649714/…Parchment

© 2022 - 2024 — McMap. All rights reserved.