5
                                                'wildignore' 'wig'
'wildignore' 'wig'      string  (default "")
                        global
                        {not available when compiled without the +wildignore
                        feature}
        A list of file patterns.  A file that matches with one of these
        patterns is ignored when expanding wildcards, completing file or
        directory names, and influences the result of expand(), glob() and
        globpath() unless a flag is passed to disable this.
        The pattern is used like with :autocmd, see autocmd-patterns.
        Also see 'suffixes'.
        Example:
                :set wildignore=*.o,*.obj
        The use of :set+= and :set-= is preferred when adding or removing
        a pattern from the list.  This avoids problems when a future version
        uses another default.

It seems that this documentation would indicate that wildignore will cause functions like glob/expand/globpath to ignore the patterns in this variable.

Currently this is my setting:

wildignore=*.o,*.a,*.so,*.pyc,*.swp,.git/,*.class,*/target/*,.idea/

If I use glob:

:echo glob(".gi*")
.git
.gitignore

This is not what I'd expect from the documentation.

However, if I do:

:edit .gi<TAB>

It will instantly complete to .gitignore and subsequent double taps of will not cycle to .git. So it seems that :edit uses wildignore as I'd expect.

  • Just a thought, but shouldnt wildignore affect only wildmenu responses, and maybe some other plugins that use it, but not a vanilla function such as glob? I still agree the doc is off if this is the case. – Cpt. Stroparo Mar 5 '19 at 1:28
4

One of the items in your 'wildignore' list is .git/. I think you'll get the behavior you're looking for if you change it to .git,.git/*.

But to understand what's going on here, I think you have highlighted a behavioral difference between the way completion and functions like glob() work. My guess is that the functions don't identify a directory called .git as a match for the pattern .git/ because the trailing slash isn't actually part of the name. However, for tab completion, the trailing slash is often inserted for directories as a convenience. Maybe for completion, the trailing slash is added to the input before it gets filtered by the pattern.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.