pkpztq
Last Updated: February 25, 2016
·
822
· sheerun
Photo on 08.01.2013 at 04.15

Natural copying and pasting in Vim

vim

Add to your .vimrc:

vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]

vmap <silent> <C-c> "+y
nmap <silent> <C-c> "+yy
vmap <silent> <C-v> "+p
imap <silent> <C-v> <Esc>"+pa

This does two things:

  • Cursor is placed at the and of yanked / pasted text
  • You can use Ctrl-C and Ctrl-V for system clipboard interaction (it doesn't change Ctrl-V in normal mode, use o C-v to paste code)
Say Thanks
Respond

1 Response
Add your response

8046
Fe0ce83e4e1683c3aeda7cb2160e06a1

I don't like remapping C-c/C-v. I'm using <Leader>y and <Leader>p

over 1 year ago ·