Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cutting and pasting from vim and tmux

Tags:

vim

tmux

Is cutting and pasting from a vim session started from tmux completely broke?

If I want to cut from a github web into my vim session or vice versa, it rarely works or if it does, it is completely broke.

I have had others confirm that they find this difficult.

I am running on the following:

  • OS X 10.8.2
  • Vim 7.3
  • tmux 1.7

I am referring to the normal cut and paste commands Cmd + c and Cmd + v.

Are there any fixes or workarounds?

like image 673
dagda1 Avatar asked Dec 26 '12 13:12

dagda1


1 Answers

  1. In Vim, you don't use Cmd+c/Cmd+v to "copy" and "paste": you use y/p, possibly with a register ("*y/"ap) to "yank" and "put".

  2. If your Vim has clipboard support built-in, "*y should be enough to yank from Vim and "*p should be enough to put from another application. * is the "clipboard" register.

  3. Again, supposing Vim has clipboard support, adding set clipboard^=unnamed to your ~/.vimrc should synchronize Vim's default register and the clipboard register; allowing you to simply use y˘and p.

  4. The tmux/vim combo has a long standing issue with system clipboard on Mac OS X. It is fortunately very quick and easy to fix.

To see if your Vim build has clipboard support, type this command in your shell:

$ vim --version | grep clipboard

A + before a feature means "supports", - means "doesn't support".

like image 137
romainl Avatar answered Nov 15 '22 15:11

romainl