0

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 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 May 17, 2022 at 18:47

2 Answers 2

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 May 17, 2022 at 18:51

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.