7

I'm using (roughly) the same config for my mac and my ubuntu machine. I use

set clipboard=unnamed,unnamedplus

To conveniently share vim's clipboard with the system clipboard. However, lately the clipboard sharing broke under Mac OS X.

I have no idea what I did to break it, it still works fine under ubuntu. I've tried completely removing and reinstalling vim (via homebrew), deleting my .vimrc and .zshrc files, and still it doesn't seem to work.

Now, when I have

set clipboard=unnamed,unnamedplus

I cannot paste at all with vim. When I set

set clipboard=

then I can at least paste in vim, but of course it doesn't share the system clipboard (duh). Using :reg confirms that with anything other than set clipboard=, nothing is written to vim's registers. :version gives me +clipboard and +xterm_clipboard. I've also tried it in iTerm2 and Terminal.app, both in and outside of tmux (same results). Also, manually copying to the registers ("*yy, "+yy) didn't work.

Interestingly, the the GUI-version (MacVim 7.4-74, also installed via homebrew) still functions fine in this regard, I can happily copy/paste to/from the system register there.

Do you guys have any ideas? Cause I'm desperate at this point...

Here's my .vimrc: https://github.com/DeX3/dotfiles/blob/master/.vimrc

5
  • Do you use tmux?
    – romainl
    Apr 27, 2015 at 7:38
  • @romainl yes, the error occurs both inside and outside of tmux though
    – DeX3
    Apr 27, 2015 at 7:52
  • 2
    I would recommend using MacVim instead, as it plays better in Mac OS. You don't have to use the GUI version -- mvim -v will work in the terminal.
    – tommcdo
    Apr 27, 2015 at 11:30
  • @tommcdo in mvim -v it works! Both in and outside of tmux! Boy am I glad... I'm just gonna alias that now. No idea what broke it in the first place, but I'm just glad this works. Thanks! If you make your comment an answer, I'll accept it.
    – DeX3
    Apr 30, 2015 at 10:36
  • I have the same issue, also in macvim.
    – dimid
    Jun 6, 2017 at 17:46

2 Answers 2

4

MacVim

Under OS X, it's best to use MacVim. OS X behaves differently to other operating systems when it comes to things like clipboard management. MacVim is specifically designed to address the areas where Vim falls short on the Mac.

Coming to a terminal near you

Although MacVim runs as a GUI (like GVim) by default, you can use MacVim in the terminal using mvim -v. I'd recommend an alias such as the following (I'm using bash syntax; adjust according to your shell):

alias vim='mvim -v'
1
  • Alternatively, use Homebrew and run brew install vim --override-system-vi.
    – squarefrog
    Apr 30, 2015 at 14:04
0

Try this remap

nnoremap y "+y

this will yank to the system clipboard So no need to use MacVim and this works for neovim

1
  • Welcome to Vi and Vim! Just a note that your answer only works in normal mode (so v_y is unaffected). I suspect the real issue for the OP is either in the config or the use of an outdated version, as "*y works for me on a mac with terminal vim.
    – D. Ben Knoble
    Aug 7, 2021 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.