Move the cursor to the place you wish to insert the copied line.
Place the cursor on the line you wish to copy.
Press the ESC key to be sure you are in vi Command mode.
The vi p and P commands "put" the line back into the file just after (p) or just before (P) the line on which the cursor is resting. That is, it copies the line for you to put into the file immediately. The vi yy command "yanks" the current line into the vi general buffer. To copy text into a buffer, use the vi yank command. When you quit vi, all the buffers are emptied they are temporary storage that only lasts for your current vi work session. This feature is particularly useful if you are editing a file that contains a lot of boilerplate text or repetitive code. You can also delete or copy lines into temporary files called named buffers that will let you reuse those lines during your current vi work session. Whenever you delete something from a file, vi keeps a copy in a temporary file called the general buffer. If you've deleted something by accident, the u command will restore it to your file. The u (undo) command undoes the most recent thing you've done in vi. The simplest case would be using the vi command mode command: Each buffer acts like temporary memory, or, as some programs call it, a "clipboard" where you can temporarily store information. The vi editor allows you to copy text from your file into temporary buffers for use in other places in the file during your current vi work session.