j9wnfw
7.388K
· December 2012 ·
56b0b10e79eea3c98fb88c91ef0c6a5e

Vim & Tmux & System Clipboard

So you use terminal vim, and you use tmux, and you want everything you yank, delete, or cut to go to your system clipboard, and you want to be able to paste code you copy from the internet. Here's what you do in 5 easy steps (assuming you're on OSX and have homebrew):

  • since the version of vim that comes with OSX does not support using the system clipboard, we'll use mvim instead. This command will also alias vim, vi, view, vimdiff, etc. (credit to @smlstvnh):
    brew install macvim --override-system-vim && brew linkapps

  • and we'll use this handy plugin to get tmux to play nice with the system clipboard:
    brew install reattach-to-user-namespace

  • tell vim to use the system clipboard:

    • in .vimrc: set clipboard=unnamed
  • tell tmux to use the system clipboard:

    • in .tmux.conf: set-option -g default-command "reattach-to-user-namespace -l bash"

View this and other helpful system configurations here

Sign in or sign up to add your response.

7 Responses

6155
Ea2273b4310db9ac0109dfaefd489a06

brew install macvim now

over 1 year ago ·
6173
56b0b10e79eea3c98fb88c91ef0c6a5e

thanks! updating

over 1 year ago ·
13360
89acea45d9c5ee7f36ab3981262bded0

brew install macvim --override-system-vim && brew linkapps

This will alias vim, vi, view, vimdiff, etc.

To see all commands aliased, you might try ls -l /usr/local/bin | grep macvim

over 1 year ago ·
13409
56b0b10e79eea3c98fb88c91ef0c6a5e

thanks @smlstvnh, updated!

over 1 year ago ·
17714
9b029fbe569b3af35c235aedb2420b7b

Awesome! Automatically sending to tmux when I yank from vim is something I had been looking for, it totally worked. Thanks.

over 1 year ago ·
23653
57miveqr normal

is there an equivalent package in apt-get ?

6 months ago ·
27327
56b0b10e79eea3c98fb88c91ef0c6a5e

@louisgmoore so sorry for the delayed response! there was something funky going on with coderwall and it wouldn't let me comment, but now I can :).

From a quick search it looks like you might have some luck with xclip or xsel, but I haven't tested it myself.

about 2 months ago ·
Featured Programming Job

Full Stack Rails Developer
·
New York or Remote
·
Full Time
Search all programming jobs