Question

In zsh, if you type ls <Tab> in your home dir, it'll show all non-hidden files in your home, then each <Tab> cycle through the file names.

When the current highlighted filename is what I want, if that item is a dir, I type / to confirm my selection, if it's a file, I use <Space>.

As this post instructs, I have added these two lines in my .vimrc to give vim zsh-like completion.

set wildmode=longest,list,full
set wildmenu

But when vim is cycling through the options, how can I confirm a selection?
Like in my home dir I start vim, and :e + some tabs, when the selection is on my document dir, how can I confirm it? <Enter> would finish the command, <Esc> or <C-c> cancels it, while / appends a backslash so the command becomes :e document//--not what I want.

Was it helpful?

Solution

From the vim documentation (:help wildmenu):

While the "wildmenu" is active the following keys have special meanings:

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

So I think that gets at least part of what you're after.

OTHER TIPS

Just in case anyone else (like me) ends up here and feel like @Geoff answer doesn't feel really vim-like.

I found that Ctrl + D does exactly what OP was asking. More information in :help cmdline-completion

I use <space> to select.

cnoremap <expr> <space>  wildmenumode()?"\<space>\<BS>":"\<space>"

Old post but I was looking for the same answer. According to :help wildmenu:

CTRL-Y      - accept the currently selected match and stop
              completion.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top