5

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?

2 Answers 2

5

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

2
  • 2
    why would they do that ?? now I have to recompile from source Commented Aug 24, 2021 at 16:31
  • In Big Sur it is compiled with +clipboard Commented Aug 24, 2021 at 16:53
2

Additionally you can install the program MacVim, which is a version of Vim 8 compiled for Mac, including a GUI. However you don't need the GUI, you can just link the mvim executable to vim somewhere on your $PATH, and the + register will work as your clipboard just like you are used to.

MacVim is also recommended if you are going to install some recent plugins like YouCompleteMe.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .