How do I recover the last small deletion without disrupting my numbered registers?
Answer
"-
Explanation
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register). Unlike the numbered registers "1–"9 which only track linewise or multi-line deletes, "- captures word deletions, character deletions, and any {operator}{motion} that stays within a single line — giving you a dedicated rescue slot for small edits.
How it works
- Any deletion shorter than a full line is saved to
"-automatically - Paste it anywhere with
"-p(after cursor) or"-P(before cursor) "-is overwritten by the next small delete — but it does not disturb registers"0–"9- This means you can yank a large block (
yy), make several small deletions, and still paste the original yank with"0pwhile recovering the most recent small delete with"-p
Example
Suppose your cursor is on important:
This is important for the function.
You accidentally run dw, removing important. Later you yank a different line, then realise you need the word back. Because the deletion was one word (less than a line), "-p restores it exactly:
"-p
Result:
This is important for the function.
Tips
- Use
:registers -to inspect the current contents of"-at any time - For linewise deletions, check
"1(most recent) through"9(oldest) - Combine with
"0pfor the last yank — together"0and"-cover most accidental-overwrite scenarios without needing named registers