Delete without losing your yank
"_diw
Example
Normal mode. Yanked blue with yiw. Cursor on remove in keep remove.
keep removeCursor on line 1, column 6- "_diw Delete remove · trailing space stays; blue still saved
- p Paste blue · keep blue
keep blueCursor on line 1, column 9Details & 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
- Yank the text you want to keep.
- On an unwanted word, type "_diw.
- Use p or P to put the saved yank.