||Oracle Tips by Burleson
Cutting, Copying, and Pasting text
Any of the text deleting commands discussed earlier work similarly
to the cut feature of Windows in that they place the deleted text in
a buffer area for potential retrieval (pasting) later. In Windows
the buffer is referred to as the clipboard.
In vi there is a default (unnamed) buffer and 26 specifically
referenced buffers each identified by one of the letters of the
alphabet (a, b, c, d, etc.). In order to referenced one of the named
buffers, you precede the buffer identifier character with a quote.
So, “a refers to buffer a, “b refers to buffer b, and so on.
When you use one of the delete commands, the text is cut from the
document and placed in the default buffer. To retrieve text from the
default buffer you can use the P (upper case) command to paste the
default buffer before the current cursor line or p (lower case)
command to paste the contents of the buffer after the current line.
Therefore, a 5dd command followed by a cursor movement and a P
command would cut 5 lines of text and place them before the line
where the cursor was moved.
Instead of cutting (deleting) text, you can also copy text from a
file using the yy (yank) command. The yank command gives you the
option of copying text to one of the specific named buffers. Whereas
yy copies the current line to the default (unnamed) buffer, “cyy
would copy the current line to the buffer named c.
Be forewarned that issuing multiple yank commands to the same buffer
(default of specifically named) without intervening paste commands
will result in buffer overwrites. In other words, you cannot yank
line 5 to buffer a, then yank line 7 to buffer a and expect to be
able to paste both lines 5 and 7 somewhere.
When you yank line 5, it is placed in buffer a as requested, but
when you follow with a command to yank line 7 to buffer a, line 7
will overwrite (clobber) line 5 which is sitting in the buffer. This
is one of the reasons for providing multiple named buffers to use
for multiple successive yanks.
Copy and paste commands
Copy (yank) the current line of text into the default (unnamed)
Copy (yank) the current line of text into the buffer named b
Copy 5 lines of text to the default buffer
Paste the default buffer after the current cursor line
Paste the default buffer before the current cursor line
Paste the contents of named buffer b before the current cursor line
The above book excerpt is from:
Working Examples of Linux Command Syntax