Search code examples
vimyank

vim: copy into system clipboard not working


In my .vimrc I have those two lines for copy and paste into the system clipboard:

nnoremap <Leader>p "+p
nnoremap <Leader>y "+y

Weirdly the remapping of pasting works fine, but I can't copy any lines. If I press the buttons "+y it works and the highlighted text is in my system clipboard, but if I use < Leader> y it is only copied into a register inside vim, but not into the system clipboard.

Some help would be great!


Solution

  • If you use your mapping in Visual mode, you have to use vnoremap or noremap, instead of nnoremap (which is for Normal mode only).

    See :h map-overview for details.