Swap and Duplicate Lines
ddp swaps two lines. yyp duplicates one.
Two of the oldest Vim recipes: ddp moves the current line down past the next one (a swap); yyp duplicates the current line. Both compose primitives you already know.
Two recipes you'll see in every "Vim tricks" list. They aren't features โ they're compositions of primitives that happen to do something useful.
| Recipe | Effect |
|---|---|
| ddp | Swap current line with the one below |
| ddkP | Swap current line with the one above |
| yyp | Duplicate current line below |
| xp | Swap two characters |
Watch
- ๐บ #0461 xp โ Transpose Characters (not yet published)
- ๐บ #0462 deep โ A Vim Myth (not yet published)
See also: Delete, Yank and Put