Search code examples
vim

Vim command line mode - how to confirm selection?


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.


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.