Vim Recall繁體中文

Delete without losing your yank

"_diw

Example

Normal mode. Yanked blue with yiw. Cursor on remove in keep remove.

Before
keep remove
Cursor on line 1, column 6
  1. "_diw Delete remove · trailing space stays; blue still saved
  2. p Paste blue · keep blue
After
keep blue
Cursor on line 1, column 9
Details & Vim help

Send a deletion to the black hole register instead of replacing useful register contents.

Keep a copied value available while removing surrounding clutter.

The double quote selects a register; _ is its name. Deleted text is discarded, so undo is the way to recover it.

Register 0 and the unnamed register initially contain the characterwise text blue. Delete remove with "_diw, then paste with p.

Try it in Vim

  1. Yank the text you want to keep.
  2. On an unwanted word, type "_diw.
  3. Use p or P to put the saved yank.