Copying text to diff files within Vim


I have been working with my raspberry pi as I get practice with networking skills, and with these really long key spaces, I had been having to peer closely at the key strings and type them into the appropriate file. Sometimes more than once a day, as I had been experiencing Rpi technical difficulties (read, I had to write the OS onto a new SD card several times in the period of a day or two. Very aggravating).

Then I learned about the option for copying a line of text in one Vim file (‘yy’ command) and then using ‘gt’ command to switch to another tab. There, I could use the ‘p’ command to paste it into the second file. This doc was helpful for that, as well as this one too.

vim -p <file1> <file2>

Once those two files were added to the command, I could then move from one to the other and paste those long key strings. The other thing that I learned was that I could use the scp command to send one file (where I had the key string saved) to the raspberry pi – this doc was helpful.

scp test.txt jayesh@10.143.90.2:/home/jayesh

To recap, I typed in the key strings into a file and saved them on a my local computer. Then, I copied that file to my raspberry pi computer using scp. Finally, I created the file needed for a program I was working on and was able to use the ‘gt’ command to ‘yy’ (copy) and then ‘p’ (paste) the values, saving me a lot of work!


Leave a comment