Copying with vim and tmux

The problem: you have two vim windows opened side-by-side in two tmux panes, and your vim configuration does not allow copying into the clipboard.

The solution: select text to copy using the Visual mode in vim, then :w buffer_file; in the other vim window, :r  buffer_file where you want to copy. Here’s the situation. I often use vim when working on a remote machine. I also use tmux to split my wide display into parallel panes, which is extremely useful for editing  one file while referencing another. The first approach is to enable the copy into clipboard mode of vim, but I have no control over the vim configuration. The second approach is to copy using normal copy technique on the console (i.e. highlight text and then right-click / copy or Ctrl/Cmd C), but this does not work when you have two tmux panes running side by side. Hence the above solution.

Comment: This solution is so lame now that I know that Vim also support splitting a window. Personally I use NerdTree but just using the built-in feature of Vim should work too.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s