editing
p / P
Paste the contents of the unnamed register: p pastes AFTER the cursor (or below the line, for a linewise yank), P pastes BEFORE the cursor (or above the line). Works with anything you dd'd, yy'd, or x'd.
p P (normal / visual mode) Variations
| Keystroke | Effect |
|---|---|
| 3p | Paste the register contents 3 times |
| "0p | Paste from the yank register (survives deletes) |
| "+p | Paste from system clipboard |
| gp | Paste and leave cursor AFTER the pasted text |
Examples
yyp Duplicate current line below
ddP Move current line up by one
"+p Paste from OS clipboard
Gotcha
Every d, c, s, x overwrites the unnamed register — if you delete something and then try to paste your earlier yank, it's gone. Use register "0 for the last yank specifically.
Related
yy
'Yank' (copy) the current line into the unnamed register — Vim's word for copy. Combine with p/P to duplicate lines without touching your system clipboard.
dd
Deletes the current line (and stores it in the unnamed register, so you can paste it back with p). The bread-and-butter 'get rid of this line' command.
u / Ctrl-R
u undoes the last change; Ctrl-R redoes it. Vim has a full undo TREE (see :undolist and g-/g+) but for day-to-day work these two keys are enough.
i / a / o / O
The four ways to enter insert mode: i inserts BEFORE the cursor, a inserts AFTER it, o opens a new line BELOW and enters insert mode, O opens a new line ABOVE. Choosing the right one saves a motion or two before you start typing.
x
Deletes the character under the cursor — Vim's equivalent of the Delete key. It's a cut, so the character lands in the unnamed register.