In vi, how do I name cut buffers?
In vi, you can use the double quote
( " ) operator to name cut buffers. For
example, you could type the double quote character, then the letter
e , then use dd to delete a line:
"edd
Until you exit vi, you can paste that deleted line by typing the
double quote character, then the letter e ,
then p :
"ep
You can use this operation preceding any delete, yank, or paste command in vi to save or recall any text you like. This is particularly handy if you're cutting and pasting between two files. For example, you can start vi with the command: vi oldfile newfile
Then, if you want to cut the first three lines from
oldfile and put them in newfile, use the
following commands:
| Command | Action |
|---|---|
"z3yy |
Place three lines in cut buffer 'z' |
3dd |
Delete the lines |
:w |
Write the file out |
:n |
Edit the next file |
"zP |
Put or paste the lines above the first line |
:w |
Write the file out |
:e # |
Go back to the previous file you were editing |
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
Last modified on August 22, 2008.







