4

Is there a way to exclude specific files and directories from Vim's path?

I was hoping a syntax like this would work:

set path+=./**,!./ignoredirectory,!./ignoredirectory2,!./ignorefile.txt

I would use wildignore but I don't think it supports relative path expansion if I used something like set wildignore+=ignoredirectory,ignoredirectory2,ignorefile.txt.

  • 1
    It's not clear to me what you are trying to accomplish? Your example doesn't make any sense, what behaviour exactle do you want? – Martin Tournoij Feb 15 '15 at 0:08
2

I did a bit of experimentation with wildignore. I don't think it supports relative paths, or even absolute paths.

Here's what I have:

  1. A file at ~/devel/scratchpad/c++/ms.cpp
  2. Vim opened with current directory ~/devel
  3. :set path=~/devel/**

I tried:

set wildignore=scratchpad/**/*
set wildignore=~/devel/scratchpad/**/*
set wildignore=./scratchpad/**/*
set wildignore=/home/muru/devel/scratchpad/**/*
set wildignore=*/scratchpad/**/*
set wildignore=**/scratchpad/**/*

Only the last two prevented tab completion from filling :find ms. to :find ms.cpp. I'm not sure how to explain the results.

| improve this answer | |
1

Why do you think such a syntax should work?

:h :set is your entry point to Vim's documentation on :set. Scroll down a little to find out how to remove an item from a comma-separated list:

:set path-=whatever
| improve this answer | |
  • I was hoping to be able to append ** to the path, and then remove specific files and directories that would be matched by **. I cannot remove a specific file using set path-=whatever when I use the wildcard ** . – user489 Feb 14 '15 at 22:26
  • Use :help wildignore to ignore specific directories and files. – romainl Feb 14 '15 at 22:28
  • I dont believe that wildignore supports relative paths.. – user489 Feb 14 '15 at 23:20
  • Observation is better than belief. – romainl Feb 15 '15 at 10:04

Your Answer

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