| In vi terms, "yank" is copy, "put" is paste and "delete" is cut. |
| Key |
Meaning |
Key |
Meaning |
Key |
Meaning |
| Y |
yank to the end of the current line |
yy |
yank the entire line |
5yy |
yank the current line plus the next 4 |
| yH |
yank all lines from the current to the top of the screen |
yL |
yank all lines from the current to the bottom of the screen |
y5W |
yank to the start of the 5th word to the right |
| D |
delete to the end of the current line |
dd |
delete the current line |
dG |
delete to the end of the file |
| dH |
delete all lines from the current to the top of the screen |
dL |
delete all lines from the current to the bottom of the screen |
d5W |
delete to the start of the 5th word to the right |
| x |
delete the character at the current cursor position |
X |
delete the character to the left of the cursor |
5x |
delete the next 5 characters |
| y'a |
yank (copy) to bookmark a |
y'z |
yank (copy) to bookmark z |
| d'a |
delete to bookmark a |
d'z |
delete to bookmark z |
| vi stores yanked and deleted data in the same piece of memory (think of it as the clipboard), so a yank followed by a delete loses the text that was yanked. |
| P |
put the text in the yank/delete buffer before the current cursor position |
p |
put the text in the yank/delete buffer after the current cursor position |
| yyp |
copy the current line to the line below |
ddp |
swap the positions of the current line and the line below it |
xp |
swap the positions of the current character and the character to the right of it |
| Aswell as the clipboard, vi provides 26 "named clipboards" that you can yank and delete text into. Helpful if you know you need to copy/cut and paste multiple bits of text. The named clipboards are a to z. N.B These named clipboards are the only way to cut/copy and paste text between files in a vi session. |
| "ayy |
yank the current line into name clipboard a |
"ap |
paste the tet from named clipboard a to the line below. |
"ay$ |
yank to the end of the line into named clipboard a |
| "Ayy |
yank the current line onto the end name clipboard a |
"AdL |
cut to the bottom of the screen onto the end of named clipboard a |
| Aswell as the clipboard, vi provides 9 "delete clipboards" deleted text is copied into. Helpful if want to retrieve the text from 4 deletes ago. The delete clipboards are 1 to 9. |
| "4p |
past the delete from four deletes ago below the current line |