Search code examples
vimtmux

How to copy from tmux running in PuTTY to the Windows clipboard


Environment: I am running tmux in PuTTY, on a Windows 7 laptop. I do SSH to Linux systems while working.

I have to solve two glitches with tmux, before using it for all my needs.

  1. I have to copy some text to the Windows Notepad application from Vim or the tmux terminal. I have enabled mouse support for both Vim and PuTTY.

    I have tried "*y and "+y, but neither of them work. If I use PuTTY's ability for copy then it copies the content of adjacent grids also.

  2. I have to copy some content from a Vim file in one pane to a Vim file opened in another pane. Is there a Vim trick for this? I don't want to use <C-b>[ way of doing it.

Problem 1 is haunting me more, because there is a workaround for problem 2.


Solution

  • PuTTY is just a terminal emulator; the Vim registers * and + are concerned about the X selection and clipboard; there's no overlap.

    PuTTY only allows you to copy the selected terminal contents to the Windows clipboard; when you run tmux, that will inevitably include the window layout.

    You need to switch from PuTTY to something that allows real integration, like the Cygwin XWin server, which is a real X Server that integrates the X clipboard with the Windows clipboard. Instead of inside the PuTTY session, you'd ssh -X into your server, and launch Vim in a Linux terminal, or GVIM directly. Then, yanking via "+y will work as you'd expect.

    Alternatively, if you want to keep using PuTTY, you'd have to use some workaround, like :writeing the selection to a local file, and transferring that to Windows via scp, for instance.