How do I access previous deletions from the numbered registers?
Answer
"1p through "9p
Explanation
Registers 1-9 contain the last 9 deletions or changes that are at least one line long. This gives you a deletion history.
How it works
"1contains the most recent deletion (one line or more)"2contains the second most recent- Up to
"9which contains the 9th most recent - Each new line-or-more deletion shifts the previous ones down
Example
You delete three different lines with dd. Now:
"1ppastes the most recently deleted line"2ppastes the second-to-last deleted line"3ppastes the third-to-last
Tips
- Small deletions (less than one line) go to the
"-register instead "1pu.u.u.lets you cycle through registers: paste"1, undo, paste"2, etc.- After
"1p, the.command advances to the next register - This is useful for recovering accidentally deleted text
:reg 1 2 3shows the first three numbered registers