MacOS – Copying text in vim to the global clipboard

macosvi

On my linux computer I am able to copy text to the clipboard with the command "+y. How do I do the same on Mac?

Best Answer

macOS version of vim is compiled with -clipboard (you can check with vim --version). So there's no shared clipboard available. In this case you can download/recompile new vim or you can use system command pbcopy (man page). Here's how to use it as CTRL ⌃+C shortcut:

map <C-c> y:e ~/clipsongzboard<CR>P:w !pbcopy<CR><CR>:bdelete!<CR>

Add this to your ~/.vimrc file.

Explanation of this command can be found here: vimtips @ quora