mhinz/vim-galore

Saner command-line history: preserve default behaviour of ctrl-p/ctrl-n in wildmenu

rafikdraoui opened this issue · 1 comments

When using the wildmenu, <c-p> and <c-n> go to "previous" and "next" item, while <down> and <up> go "down into subdirectory" and "up into parent directory" (see :h 'wildmenu')

By remapping:

cnoremap <c-n> <down>
cnoremap <c-p> <up>

as proposed in Saner command-line history, we lose the ability to select previous/next matches in the wildmenu with Ctrl-P/Ctrl-N. And perhaps more seriously, using those keys will "mess up" the completion by filling the command line with unexpected suggestions from different directories.

I've been using these mappings instead, and they work quite well for me:

cnoremap <expr> <c-n> wildmenumode() ? "<c-n>" : "<down>"
cnoremap <expr> <c-p> wildmenumode() ? "<c-p>" : "<up>"
mhinz commented

Thanks! ✨