Lorin Hochstein
Lorin Hochstein

Reputation: 59202

vim autocomplete directory name

When I'm using filename autocompletion in command-line mode, how do I do select the current option to autocomplete?

For example, let's say I want to open the file ~/dev/myproject/foo.c

I start by typing:

:e ~/dtab

And I hit tab a couple of times until I see

:e ~/dev/

What do I press next to get vim to autocomplete the directories within ~/dev/?

If I hit enter, vim will open a buffer with the directory listing, which is not what I want.

I can hit / and then tab, but then I get an innocuous but aesthetically displeasing double-slash in my path:

:e ~/dev//tab

I can also hit "m", and then tab, which will work:

:e ~/dev/mtab

But what if I didn't remember that the next directory started with "m"?

How do I tell vim in the above example that "dev" is the autocomplete option that I want, and then to continue to do autocompletion for the next part of the path?

Upvotes: 3

Views: 1015

Answers (1)

Amadan
Amadan

Reputation: 198324

:h wildmenu

<Down> - in filename/menu name completion: move into a subdirectory or submenu.

Upvotes: 5

Related Questions