2

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.

2
  • 1
    Thought, PuTTY does not know anything about remote clipboard. So, it can copy only visible parts of texts.
    – Maximus
    Oct 1, 2012 at 21:38
  • 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.
    – dza
    Apr 9, 2017 at 2:28

2 Answers 2

2

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.

2
  • 1
    was expecting some way to hook up the 'system' clipboard via "+ or "* with putty's clipboard...
    – gcb
    Oct 1, 2012 at 22:29
  • 1
    It's not true that yanking does not work between separate Vim processes. It does work if you are in Windows or in Unix and are running in an X client, either vim in a terminal or gvim. See ":help 04.7" in Vim's built-in help.
    – garyjohn
    Oct 2, 2012 at 1:21
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .