1

I am using ConEmu terminal to access files in the Linux distro of my Windows 10 machine. I open text files with Nano or VIM, but I am having trouble copying entire text files back to Windows.

Obviously selecting the texts with the mouse and copying, then going back to Windows and pasting works fine. However when the file has hundreds of lines this does not work.

In Nano, I have tried things like turning on soft wrap (Esc+$) and making the font size small before copying. It is not desirable for super large files.

In VIM I tried to install VIM-GNOME then yanked the texts with %y+ but this buffer cannot be copied back into Windows.

I could try to locate the Linux file inside Windows Explorer then opening with a Windows text editor but this is a bit inconvenient and dangerous.

How can I copy the content of an entire file (or a large chunk of it) and pasting from Linux Subsystem to Windows?

I am using ConEmu terminal but if there is a solution with another terminal I would like to try also.

Thanks!

1
  • On closer look I believe your question can largely be answered by the answers here. If there is still a reason (beyond "dangerous", which is no longer an issue in recent versions, if done properly) that you would not like to access those files directly, please mention it here. – Bob Aug 28 '19 at 5:02
2

Moving large files through the clipboard is, as you have discovered, a somewhat awkward experience. You're better off copying the entire file.

I could try to locate the Linux file inside Windows Explorer then opening with a Windows text editor but this is a bit inconvenient and dangerous.

There are two right ways and one wrong way to do this.

The first method is to use WSL to copy the file into a Windows directory. This means anything under a /mnt/<driveletter> mountpoint. For example, /mnt/c/Users/Your.Username/Documents would map to your Windows Documents folder. This is entirely safe - though you may need a text editor capable of reading LF line endings to open the file correctly.

Alternatively, if you are using Windows 10 v1903 or newer, you can safely access WSL directories and files via the wsl$ share. The easiest way is to open the WSL directory via explorer, by running explorer.exe . within WSL.

The dangerous method involves accessing the WSL directories via AppData. Do not do this.

4
  • Thanks! What if the files are on a server? – Freelensia Aug 28 '19 at 10:45
  • 1
    @Freelensia That would depend on how you are accessing the server. For example, if you are using SSH, you can use SCP or SFTP to copy the files back to the local machine. – Bob Aug 28 '19 at 12:53
  • Thanks @Bob. I am accessing via SSH. But copying back to the local machine will only copy it to the WSL, not back to Windows. I need a way to SSH into Linux server from Windows then get the file back to Windows. – Freelensia Aug 29 '19 at 11:15
  • 1
    @Freelensia If you SCP into a /mnt/<driveletter> directory, it will end up on Windows. e.g. scp user@host:/path/to/remote/file /mnt/c/Users/Your.Username/Documents/ – Bob Aug 29 '19 at 11:20

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.