Suppose the directory tree looks like this:

├── data
│   └── file.txt
└── data2
    └── file2.txt

When Vim is launched at rootdir and configured with :set path=data*, it is unable to :find either file:

:find file.txt
E345: Can't find file "file.txt" in path
:find file2.txt
E345: Can't find file "file2.txt" in path

However, if the path is adjusted to :set path=dat*, then :find is able to locate both files.

Could this be a bug in Vim? It only seems to affect file searching (:h file-searching), rather than wildcard expansion (:h wildcards), since that command-line tab completion finds both files:

:find             <Tab>
:find file.txt    <Tab>
:find file2.txt

Issue Variation: **

The above example starts half-working when using ** instead of *:

:set path=data**
:find file.txt     " Succeeds
:find file2.txt    " Fails

Deeper Directory Tree

Now suppose this is the directory tree:

├── data
│   └── subdir
│       └── file.txt
└── data2
    └── subdir
        └── file2.txt

The results of :find with different 'path' values are:

| 'path'   | :find file.txt | :find file2.txt |
| data**   | Succeeds       | Fails           |
| data*/** | Succeeds       | Fails           |
| data*/*  | Fails          | Fails           |
| dat**    | Succeeds       | Succeeds        |
| dat*/**  | Succeeds       | Succeeds        |
| dat*/*   | Succeeds       | Succeeds        |

Vim Version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 10 2020 04:05:27)
macOS version
Included patches: 1-13
  • Did you read help file-searching, where it discusses the use and details of * and **?
    – D. Ben Knoble
    Jun 7 '20 at 12:43
  • Considering I linked :h file-searching in the question, I think it gives a strong enough hint. 😏
    – mxxk
    Jun 9 '20 at 1:45
  • i know; thats why i asked—im having a hard time pinpointing what part of your expectations were based on the documentation, since (if my understanding is correct) some of the examples make a little less sense when compared with those docs
    – D. Ben Knoble
    Jun 9 '20 at 1:48
  • Based on the docs, it is not clear why data** should have an issue matching data2/ only if data/ is present. More generally, this is an example where Vim's matching of sibling directory A depends on the presence of directory B, which seems bonkers and smells like a bug.
    – mxxk
    Jun 9 '20 at 1:55

Your Answer

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

Browse other questions tagged or ask your own question.