I'm trying to select all the code in my vim editor in a putty session on my windows 10 and paste it on notepad in windows 10.

once I get into vim with terminal command vim code.s on ubuntu I've tried the widely used :%y+ but get an error saying invalid registry name so its not possible to do that on ubuntu. If any one know how to please let me know.


Use of the clipboard on Linux requires the X server, so you'd need such on your Windows system (e.g. Cygwin-X), and start the ssh session with X forwarding (ssh -X). As evidenced by the many related questions here, this is a hassle to set up.

As a pragmatic quick workaround, you can

  1. In Vim, write the selection / selected lines (e.g. with :{range}write /tmp/file) to the local (Ubuntu) file system
  2. Use another PuTTY session to pscp that file to your Windows box.
  3. Copy the file to the clipboard / directly insert its contents in a text editor.
  4. (Remove the temp files.)

For just a few lines, selection with the mouse inside the PuTTY window is the fastest, but beware of changes in line breaks, whitespace, :set number and other complications.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.