Copy line 5 into vim's clipboard (a register): jump there with 5G, then yy yanks the whole line. The file must stay unchanged.
1. talk is cheap, show me the keystrokes 2. the mouse is a rumor 3. modes are not a bug 4. speed is a side effect of precision 5. yank responsibly 6. registers remember what you forget 7. macros do the boring parts 8. :q is goodbye, not defeat
Canonical solution: 5G yy · par: 4 keystrokes (vimgolf rules — every keypress counts).
y is the yank (copy) operator; yy yanks the current line. Yanked text lands in registers — vim's clipboards. Check your registers anytime with :registers.
| Keys | What it does |
|---|---|
| yy | copy the current line |
| 3yy | copy three lines |
| 5G yy | jump to line 5, then copy it |
| :5y | copy line 5 without moving |
| p / P | paste below / above |
Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Copy line five” mission takes about a minute.
Practice free — no signup →