How do I use 'wildignore' in Vim?

后端 未结 4 1563
滥情空心
滥情空心 2021-02-12 10:23

I\'m having a lot of trouble figuring out the syntax for the wildignore setting in Vim.

Suppose I want my file finder plugin (I use Ctrlp, which uses

相关标签:
4条回答
  • 2021-02-12 10:50

    Because the title doesn't correspond to the best answer her is mine which corersponds not to ctrlp but to wildignore. Based on https://stackoverflow.com/a/579886/1170940

    Vim will ignore file patterns specified in option wildignore , so you can set them like so:

    :set wildignore=*.o,*~,*.pyc
    

    For example, my wildignore looks as such

     set wildignore+=*/node_modules/*,_site,*/__pycache__/,*/venv/*,*/target/*,*/.vim$,\~$,*/.log,*/.aux,*/.cls,*/.aux,*/.bbl,*/.blg,*/.fls,*/.fdb*/,*/.toc,*/.out,*/.glo,*/.log,*/.ist,*/.fdb_latexmk
    

    I use it for both ctrlp and NERDTree

    0 讨论(0)
  • 2021-02-12 10:52

    As BenC pointed out, Wildignore may not be the best way to ignore files if you are using CtrlP with an external search tool. Instead, you can use CtrlP's "custom_ignore" directive, as stated in their docs:

    let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
    let g:ctrlp_custom_ignore = {
        \ 'dir':  '\v[\/]\.(git|hg|svn)$',
        \ 'file': '\v\.(exe|so|dll)$',
        \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
        \ }
    
    0 讨论(0)
  • 2021-02-12 10:55

    See :help file-pattern. Basically if you just want to exclude anything that starts with a dot you can do .*.

    0 讨论(0)
  • 2021-02-12 11:00

    Concerning ctrlp.vim and wildignore specifically, 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. For instance, in your ~/.vimrc, add:

    if exists("g:ctrl_user_command")
        unlet g:ctrlp_user_command
    endif
    set wildignore+=.*
    
    0 讨论(0)
提交回复
热议问题