copying from VIM in a screen in putty under windows

5,597

Solution 1

Yanking is a feature of Vim itself which by default only works for that process. If you want yanking to utilize the clipboard you have to use "*y (current selection) or "+y (real clipboard) as described in sections 04.7 and 09.3 of Vim help. Use the following commands in Vim to look this up:

:help 04.7
:help 09.3

PuTTY however has no access to either clipboard of the machine you're connecting to.

A quick workaround would be to use the cat command on the file, not in a screen session, and then select the text in your PuTTY which automatically copies it. Doing this outside a screen session ensures you can scroll up and get all of the text.

Solution 2

Found this patch that will redirect print output (any text inside escape \e''[5i and \e''[4i) to the windows clipboard (e.g. to print "test" in bash echo -ne '\e''[5itest\e''[4i')

http://ericmason.net/putty/putty-0.60-clip.patch

if i can find a windows printer driver that sends text to clipboard instead of printing then putty can be used unmodified, just edit Terminal > Remote controlled printing > select your fake print driver

then i just need a macro to echo the escape codes and the buffer contents.

Share:
5,597
gcb
Author by

gcb

Updated on September 18, 2022

Comments

  • gcb
    gcb over 1 year

    Anyway i can get text from Vim in the windows clipboard?

    my sessions are usually via PuTTY, and almost always in a gnu screen

    if using :set mouse=v i can highlight some lines and they appear in windows' clipboard.

    but for longer texts, selecting it all, and yanking to "+ does nothing.

    • Maximus
      Maximus over 11 years
      Thought, PuTTY does not know anything about remote clipboard. So, it can copy only visible parts of texts.
    • dza
      dza about 7 years
      Use X11 forwarding and the clipboard synchronizes. For windows there's the vcxsrv server. Set X11Forwarding=yes in your sshd_config and enable in PuTTY/client also.