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 Answers
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
- 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
- to finalise selection, press
Enter
Tested in neovim v0.8.0-dev (6613f58ce)
; doesn't seem to be working in vim (8.1.3741)
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.
-
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
Cursor-Right
neovim
, by default<Right>
seems to just focus the next option