Reputation: 8885
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?
Upvotes: 4
Views: 611
Reputation: 404
This was probably a bug which was fixed by the Vim patch 8.2.2221.
Upvotes: 0
Reputation: 172550
Christian Brabandt came up with a different solution on vim_dev: For your original mapping to work, you need to set 'wildcharm'
to the same value as 'wildchar'
:
:let &wildcharm = &wildchar
:cnoremap <C-j> <DOWN>
Upvotes: 5
Reputation: 172550
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()
Upvotes: 4