Describe the bug
The documentation for wildmenumode() provides an example to make <c-j> work like <down> in wildmode:
:cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
After creating that mapping, using <c-j> when the wildmenu is shown results in ^I being appended to the command line command.
The following mapping—intended to highlight the issue as opposed to be useful on its own—also encounters the problem.
:cnoremap j <Down>
To Reproduce
Detailed steps to reproduce the behavior:
vim --clean:cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>":e / followed by <tab> to bring up the wildmenu for the root directory.<C-j>, which should "work like <down>".^I is appended to the command (twice), as opposed to having the same behavior as pressing <down>.Expected behavior
I was expecting a move into the selected subdirectory, which is what happens when pressing <down>.
Environment (please complete the following information):
8.2.700—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
Possible duplicate of: #4954
For a workaround, make sure that 'wildcharm' has the same value as 'wildchar' (whose default is <Tab>/9):
vim -Nu NONE +'set wildmenu wildcharm=9' +'cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"'
^^^^^^^^^^^
Or use feedkeys() with the t flag:
vim -Nu NONE +'set wildmenu' +'cnoremap <expr> <C-j> wildmenumode() ? feedkeys("\<down>\<tab>", "t")[-1] : "\<c-j>"'
^
See also:
Thanks @lacygoill.
(the example mapping in the documentation for wildmenumode() maps <c-j> to <down><tab>, but it seems that <down> alone works as expected, and the extra <tab> causes selection of the second item).
Closed #6045.
Fixed by 8.2.2221.