liuchengxu/vim-which-key

Cannot map :WhichKey "<BS>"

aldevv opened this issue · 3 comments

Environment (please complete the following information):

OS: Linux
(Neo)Vim version: 0.5
Have you reproduced with a minimal vimrc: yes

Describe the bug
:WhichKey "" works when typing it by hand, but mapping it to a key produces message:

E114: Missing quote ")
E116: Invalid arguments for function which_key#start

To Reproduce
Steps to reproduce the behavior:

Make some mappings with as leader (optional)
:nnoremap :WhichKey "<BS>"<CR>
Error shows

Expected behavior
Whichkey should function as it normally does in command mode

You dont have to place your exact key code in the WhichKey argument, you can use anything you want as long as it corresponds to your registered "Key" in which_key#register.
So the following code opens up g:my_backspace_dict upon pressing :

:nnoremap <BS> :WhichKey "oof"<CR>
let g:my_backspace_dict = {
      \ 'j' : ['j', 'my mapping'],
      \ }
call which_key#register('oof', "g:my_backspace_dict")

While this does what i wanted

:nnoremap <BS> :WhichKey "oof"<CR>

I prefer this other way you mentioned, which also works.

:nnoremap <BS> :WhichKey "\<BS\>"<CR>

hope this helps anyone.

@BrotifyPacha made a very good point here. I have added this kind of question into FAQ in README so that others can find this easier.