vim

How to make Vim yank to the OSX clipboard

Tagged clipboard, osx, vim, yank  Languages bash, vim

Add this to .vimrc:

set clipboard=unnamed

If you use Tmux you probably need this: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard

$ brew install reattach-to-user-namespace

Note, do NOT use something like this because it doesn’t work perfectly:

function! ClipboardYank()
  call system('pbcopy', @@)
endfunction
function! ClipboardPaste()
  let @@ = system('pbpaste')
endfunction

vnoremap <silent> y y:call ClipboardYank()<cr>
vnoremap <silent> d d:call ClipboardYank()<cr>
nnoremap <silent> p :call ClipboardPaste()<cr>p