Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot map :WhichKey "<BS>" #178

Closed
aldevv opened this issue Mar 20, 2021 · 3 comments
Closed

Cannot map :WhichKey "<BS>" #178

aldevv opened this issue Mar 20, 2021 · 3 comments

Comments

@aldevv
Copy link

aldevv commented Mar 20, 2021

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

@BrotifyPacha
Copy link
Collaborator

BrotifyPacha commented Mar 22, 2021

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")

@aldevv
Copy link
Author

aldevv commented Mar 23, 2021

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.

@liuchengxu
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants