Skip to content

Instantly share code, notes, and snippets.

@mawaldne
Last active December 5, 2015 18:56
Show Gist options
  • Select an option

  • Save mawaldne/b47337f05446f17a9cbf to your computer and use it in GitHub Desktop.

Select an option

Save mawaldne/b47337f05446f17a9cbf to your computer and use it in GitHub Desktop.
Vim - Automatically yank to system clipboard from Visual mode
Yank normally, but just copy it automatically to your system clipboard as well.
Added to my .vimrc. Should work from visual mode when you press y and from ex mode: 1,10YankToSystemRegister
" Auto Yank text to the OS X clipboard
function! CopyToSystemRegister()
let @*=@"
endfunction
command! -range -bar YankToSystemRegister <line1>,<line2>yank|call CopyToSystemRegister()
vnoremap y :YankToSystemRegister<cr>
@mawaldne

mawaldne commented Dec 5, 2015

Copy link
Copy Markdown
Author

set clipboard=unnamed is probably as good as it gets. Im not a fan of having everything characters go to the system clipboard though but vim registers still work fine.

@mawaldne

mawaldne commented Dec 5, 2015

Copy link
Copy Markdown
Author

Also started using yankring.vim which is awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment