Share a buffer between tmux / vim splits

tmuxvim

+-------------+
|             |
|     1       |
|             |
|=============|
|             |
|     2       |
|             |
+-------------+

Each tmux split has vim open. I would like to do stuff like yank a line from 1 and paste then into 2 with the vim shortcuts.

Best Answer

The two vim instances are completely separate from each-other, but there are two possibilities to do this.

  1. If your version of vim was compiled with X clipboard support you can use eg. "+yy to yank the current line to the X clipboard register, alternatively putting set clipboard=unnamed in your vimrc to yank to the clipboard by default. See :help registers for some information on vim registers.

  2. vim has built in support for split windows, so another option is to use the built in splits instead of using tmux window splitting. See :help windows or this linux.com article for more information about them.

To check for X clipboard support you can run vim --version and see if there’s a plus before xterm_clipboard in the output. If there’s a minus instead it means that your vim was built without X clipboard support and you’ll either have to get a copy with it, or use the second solution.

Related Question