Last Updated: February 25, 2016
·
9.987K
· davidann

Vim copy to system clipboard on a Mac

(from: http://vim.wikia.com/wiki/Mac_OS_X_clipboard_sharing)

Having trouble copying selected text from Vim (not MacVim)? Since using "+y or '"*y' in Vim on a Mac doesn't actually copy the selected text to the system clipboard, you might find it beneficial to do the following:

  1. Open your ~/.vimrc file
  2. add vmap '' :w !pbcopy<CR><CR>
  3. Save it/source the file

Voila! You can now copy to the system clipboard, in visual mode, via ''!

2 Responses
Add your response

excellent!

over 1 year ago ·

Insanely helpful. Thanks, David!

over 1 year ago ·