How do I access my delete history beyond the last delete?
Answer
"1p ... "2p ... "9p
Explanation
Vim maintains a numbered register history from "1 through "9 that stores your last 9 deletes and changes. Register "1 holds the most recent delete, "2 the one before, and so on. This gives you a 9-level undo buffer for deleted text.
How it works
- Every time you delete or change text (with
d,c,s,x, etc.), the deleted text shifts through the numbered registers "1gets the new delete, the old"1moves to"2, and so on up to"9- Text in
"9is lost when the next delete pushes it out
Browsing the history
Vim has a clever trick for cycling through delete history:
"1p " Paste the last delete
u " Undo
"2p " Paste the delete before that
u " Undo
"3p " Keep going...
Or even faster, use the . command:
"1p " Paste from register 1
u. " Undo, then repeat — Vim automatically advances to "2p
u. " Advances to "3p
u. " Advances to "4p
Tips
- Register
"0is separate — it always holds the last yank (not delete) - Small deletes (less than one line) go to the
"-(small delete) register instead - Use
:registers 0123456789to see all numbered registers at once - The
u.trick for cycling is documented under:help redo-register