jbl
jbl

Reputation: 582

vim :find command behaviour differs between "enter" and "tab"

The behaviour of :find command depends whether I press "enter" or "tab" after ":find pattern"

Here are the steps to reproduce the issue:

mkdir vim_experiment && cd vim_experiment
mkdir sub
touch sub/{riri,fifi,loulou}
vim

From within vim:

:set path=.,**
:find *ir*<CR>

-> E345: Can't find file "ir" in path

However:

:find *ir*<tab>

-> auto complete to "riri". Pressing enter opens the file correctly.

Please let me know if I can provide more information.

Upvotes: 1

Views: 37

Answers (1)

romainl
romainl

Reputation: 196751

Command-line completion expands your globs but the command itself does not.

After tab-completion, the command gets a fully qualified filename but it only gets *ir* if you don't use completion, which is not the name of an existing file.

If you want :find (or :edit, or :vsplit, etc.) to open the file matching *ir* you need to expand it first with something like that:

:find `find . -name '*ir*'`

Upvotes: 3

Related Questions