How to copy a file in Vi

How to copy a file in Vi

There was a joke who spread at one moment, regarding how to generate secure passwords and it was something like this:

“Want to generate a secure password?..take a developer inside Vim and ask him to exit”

It goes without saying that Vi or Vim are text editors which are used quite often on Linux servers and with Cloud Computing nowadays being pretty much the norm, a lot more people interact with those machines in one way or another. 

So here I am in the shoes of the previous developer trying to copy a configuration file from one machine to another. I have a “black belt” in googling stuff but a white one in Vi so “how to select everything in Vi” returns the ggVG combination.

Since I actually needed to copy to clipboard and the length of the config file was longer than what my screen was able to show, it only produced “undesirable” (not all the lines) content.

For those in need of something similar and want to copy the entire content of a file in vi/vim there is an workaround/think outside the box approach:

Don’t use Vi/Vim, use the cat command and select the content using the mouse. Or at least this approach worked for me.

Comments are closed.