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

How can I set a which-key for yank/paste? #133

Closed
Keagel opened this issue Jul 1, 2020 · 3 comments
Closed

How can I set a which-key for yank/paste? #133

Keagel opened this issue Jul 1, 2020 · 3 comments
Labels

Comments

@Keagel
Copy link

Keagel commented Jul 1, 2020

Sorry for the question, I'm just starting out with vim and I'm trying to bind <leader>y to "+y but it doesn't do anything when I use it.

nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>

[...]

let g:which_key_map['p'] = [ '"+p', 'paste' ]
let g:which_key_map['y'] = [ '"+y', 'copy' ]

Is there something I'm missing? I'm not seeing anything about this kind of keybind in the README.

@kodemaan
Copy link

kodemaan commented Jul 2, 2020

I wasn't sure what the above commands were doing and was having trouble getting those working but I was able to setup this normal command with name like this

let g:which_key_space_map = {}
let g:which_key_space_map['y'] = [ 'ggdG', 'Delete whole file' ]
call which_key#register('<Space>', "g:which_key_space_map")

I didn't see it in the docs anywhere though, I just found this .vimrc where they were doing the same thing https://github.com/PetrusZ/dotfiles/blob/c1d5d407fbfa0aa9b6cc7b838f35c29ec1cc1096/home/petrus/.vim/vimrc

@kodemaan
Copy link

kodemaan commented Jul 2, 2020

I also have the configuration of whichkey like this

nnoremap <silent> <leader>      :WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :WhichKey  ','<CR>
vnoremap <silent> <leader>      :WhichKeyVisual '<Space>'<CR>
vnoremap <localleader> :<c-u>WhichKeyVisual  ','<CR>

@liuchengxu
Copy link
Owner

@Keagel Try wrapping it with a function like #126.

@liuchengxu liuchengxu added the lhs label Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants