Last Updated: September 09, 2019
·
2.959K
· sharipov-ru

tmux 1.8 + vim/MacVim: easy OSX clipboard integration

It is very easy with latest tmux version to get working vim and MacVim with system buffers. You need just follow the simple steps and get it working!

Install or update tmux:

brew install tmux (or brew upgrade tmux)

Install workaround for accessing clipboard in OSX:

brew install reattach-to-user-namespace

Use copy-pipe command to setup v/y vim keys in tmux.conf

bind -t vi-copy 'v' begin-selection                                                                                                                                
bind -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy"

Tweak your .vimrc to use unnamed clipboard:

set clipboard=unnamed

Create new alias for mvim and vim in .zshrc or .bashrc:

alias mvim="reattach-to-user-namespace mvim"
alias vim="reattach-to-user-namespace vim"

That's it! Now every yank (y, yy) or delete (d, dd) commands will copy data to system buffer.