vimtricks.wiki Concise Vim tricks, one at a time.

How do I access text from small deletes like dw or x?

Answer

"-p

Explanation

The small delete register ("-) captures text from delete operations that are less than one line — like dw, x, dt., or cl. These small deletes don't go into the numbered registers ("1-"9), which only store line-or-more deletes.

The gap in Vim's register system

  • "0 stores the last yank
  • "1-"9 store the last 9 line-or-more deletes
  • "- stores the last less-than-a-line delete

Without knowing about "-, text from dw, x, dt;, etc. seems to vanish from the numbered registers.

Example

dd      " Deletes a full line → goes to "1
dw      " Deletes a word → goes to "- (NOT "1)
p       " Pastes from unnamed register (the word)
"1p     " Pastes the full line from "1
"-p     " Pastes the word from "-

When to use it

" You deleted a word earlier and now need it back
"-p

" You deleted a character with x and want to paste it elsewhere  
"-p

" Check what's in the small delete register
:reg -

Tips

  • "- only holds the most recent small delete — there's no history like "1-"9
  • Deletes that include a newline go to the numbered registers, not "-
  • x, dw, de, db, dt{char}, df{char}, cl, cw all use "-
  • dd, dj, d}, dG all use the numbered registers (line-or-more)
  • Understanding this register is key to never losing deleted text
  • Documented under :help quote-

Next

How do I run the same command across all windows, buffers, or tabs?