0

How can I select all text in vi so that I can copy it, and then paste it in notepad on my windows server.

I have a file with 3,000 lines in it. I cannot use FTP so I need to copy the text in the Linux environment and past it into notepad on windows.

1
  • How is the Windos and Unix machines connected? Commented May 31, 2018 at 12:04

2 Answers 2

2

I'd think vi would not be the best choice with the way it handles screen redrawing. Can you run cat filename.txt then copy it all using cut and paste?

Just to be sure, do you connect to the server with SSH? Then you could use WinSCP from your windows machine to connect to your linux box and copy the file over SSH back. You can get WinSCP here: https://winscp.net/eng/download.php

1

If you can, install the xclip package.

First, add the epel repo if using Fedora, CentOS, RHEL and then install xclip (you can follow suit for adding any necessary repo to any other distribution you might be using:

yum install epel-release
yum install xclip

If you're using Debian, Mint, or Ubuntu, it's already in the main repos:

apt-get install xclip

You can then:

xclip -i filename

That will copy all of the text inside of the file to the clipboard and make it available to paste in Windows. I've confirmed that this works by using it to copy text via ssh via Mobaxterm from Centos 7 and Debian 9 into Windows.

4
  • Note for CentOS: xclip is not part of the base repo. To install it, do a yum install epel-release && yum install xclip.
    – dr_
    Commented May 31, 2018 at 7:10
  • True. I'll add this to the answer. Commented May 31, 2018 at 11:30
  • This is Boeing and they do not allow me to install anything on my desktop or the server. I can only use the VI editor. I can only highlight about 50 lines of text and there is several thousand lines in the file. I am working on Linux x86_64 x86_64 x86_64 GNU/Linux
    – user289335
    Commented May 31, 2018 at 14:57
  • Can you not put in a request to your IT department to have them install it? As highlighting everything isn't viable in this case, the best options are one of the two answers here. Certainly they'd install a simple application for you. Commented May 31, 2018 at 18:19

You must log in to answer this question.

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