liuchengxu/vim-which-key

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

Keagel opened this issue · 3 comments

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.

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

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>

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