1

When using the vertical file/folder wild menu (ex: pressing Tab after :e or :cd ) and focused on a folder, is there a way to map a key to "move" inside that folder, and pick one of it's children ? If I press Enter, that is considered the "final answer", and the wildmenu is dismissed.

2
  • in Vim it is Cursor-Right Commented May 17, 2022 at 8:29
  • @ChristianBrabandt doesn't seem to be working in neovim, by default <Right> seems to just focus the next option Commented May 17, 2022 at 18:47

3 Answers 3

1

So after some trial and error, this seems to do the trick:

set wildcharm=<C-z>
cnoremap <Right> <Space><BS><Right><C-z>
cnoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
cnoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"

  • <Up>/<Down> selects the item above/below the currently selected one, when there is a menu open. If there is no menu, cycles between commands starting with the currently entered command (default behaviour)
  • pressing <Right>:
    • with a folder selected: closes current menu, opens a new one with files/folders inside the previously selected folder, and selects the first item - but you can still use <Up>/<Down>/<Tab> to change the selected item, and if on a folder, can press <Right> to enter it
    • with a file selected: will simply close the menu - but you'll still have to confirm the choice by pressing Enter
  • to finalise selection, press Enter

Tested in neovim v0.8.0-dev (6613f58ce); doesn't seem to be working in vim (8.1.3741)

0

By default the same keys are used for both horizontal and vertical menu. That is, <Left> and <Right> to move selection and <Up> and <Down> to move between levels.

For this reason, I'd rather recommend to set wop-=pum and stick to horizontal menu layout.

1
  • They can be remapped though; horizontal can be quite restrictive, especially when you have long file/folder names - the available space fills up quite quickly Commented May 17, 2022 at 18:51
0

According to :help 'wildmenu' :

While the menu is active these keys have special meanings:

CTRL-Y      - accept the currently selected match and stop
          completion.
CTRL-E      - end completion, go back to what was there before
          selecting a match.
<Left> <Right>  - select previous/next match (like CTRL-P/CTRL-N)
<Down>      - in filename/menu name completion: move into a
          subdirectory or submenu.
<CR>        - in menu completion, when the cursor is just after a
          dot: move into a submenu.
<Up>        - in filename/menu name completion: move up into
          parent directory or parent menu.

So just press down and for other commands like :h ...?, down accepts the item of the popup and waits for remainder of your command. Additionally you can try <C-d> or <C-f> when you are typing in command mode in Vim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.