This has been bothering me for quite a long time. I like to use wildmenu for browsing directories in command mode. The problem is that for entering into subdirectory I need to use <down>
key which is always out of reach. I tried to make some mapping to overcome this issue but without success. For instance:
cnoremap <C-j> <DOWN>
But if I press <C-j>
when I want to enter a subdirectory in wildmenu, the menu disappears and ^I
occurs at the end of the command line. Any idea how to solve this?
I can reproduce this. It looks like command-line mappings (same with <Tab>
, not just <Down>
) aren't interpreted in wildmenu mode, and instead exit it and insert the 'wildchar'
literally. You can report this to the vim_dev mailing list. I think additionally a wildmenuvisible()
function analog to the pumvisible()
would be needed, so that mappings could behave differently depending on whether the wildmenu is currently active.
You can work around the issue with feedkeys()
, though:
function! EnterSubdir()
call feedkeys("\<Down>", 't')
return ''
endfunction
cnoremap <expr> <C-j> EnterSubdir()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With