Mike Sallese
Mike Sallese

Reputation: 827

Copying all lines to clipboard from VIM in cygwin

Has anyone found a good way to copy all lines from VIM in cygwin?
I've tried yanking the lines but it doesn't go to windows clipboard. Any ideas?

This seems to be a solution but it is a lot of work for copy/paste: http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim

UPDATE: this works:

echo 'put this on my windows clipboard' > /dev/clipboard

BUT doesn't work for me because I want to copy to clipboard while SSH'd into another machine. So echo'ing/cat'ing to /dev/clipboard will put it on the other machine's clipboard, not mine

Upvotes: 2

Views: 824

Answers (2)

C.H.
C.H.

Reputation: 106

There may be better ways, but here's how I do it:

Use visual mode to highlight lines to be copied to clipboard (From command mode, v, then navigate normally to highlight).

"+y

to copy to clipboard.

Since the question asks how to copy everything:

ggVG"+y

Upvotes: 4

Camusensei
Camusensei

Reputation: 1563

This is maybe not as easy as you wanted it to be, but here is how I usually do it myself:

:w
:!cat %

This will display your file, and you can copy it from there.

Upvotes: 0

Related Questions