Where developers come to connect, share, build and be inspired.

16

Vim & Tmux & System Clipboard

3216 views

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

Comments

  • Blank-mugshot
    ivanoats

    brew install macvim now

  • Blank-mugshot
    athal7

    thanks! updating

  • Blank-mugshot
    smlstvnh

    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

  • Blank-mugshot
    athal7

    thanks @smlstvnh, updated!

Add a comment