1

In my init.vim I have this section:

let mapleader=";"

" copies to system clipboard
vnoremap <leader>y "*y

" pastes from system clipboard
vnoremap <leader>p "*p

copying to my system keyboard works fine, however, when pasting using the vnoremap motion it either inserts an empty line or the letter e never what's copied in the clipboard. however, when I do the full motion of "*p it pastes fine. Is there something I'm missing?

2
  • 1
    Are you pasting in visual mode? Nov 9 at 17:53
  • Do you still have something open in your question? How can we help you further? Nov 11 at 16:25

1 Answer 1

1

I would do:

let mapleader=";"

" copies to system clipboard
vnoremap <leader>y "*y
nnoremap <leader>y "*y

" pastes from system clipboard
vnoremap <leader>p "*p
nnoremap <leader>p "*p

Remark: copying to the system clipboard and pasting from the system clipboard can be achieve with the following option:

set clipboard=unnamed

Or in Lua for Neovim:

vim.opt.clipboard = "unnamed"
4
  • Thanks, stupidly the issue was the v since I was pasting in normal mode XD. Also I've changed my init.vim -> init.lua to vim.keymap.set({"n", "v"}, "<leader>pr", "\"*p") thanks for your help @Vivan :)
    – Ctfrancia
    Nov 13 at 11:37
  • Thanks for the feedback :-) Nov 13 at 11:44
  • If you don't know it you could be interested by the :set clipboard=unnamed option that makes that by default Vim paste from and to the * register. Nov 13 at 11:45
  • 1
    thanks I didn't know about that option to set (for anyone using lua it's vim.opt.clipboard = "unnamed"
    – Ctfrancia
    Nov 14 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.