The tip title refers to Ctrl+U which is similar but not quite the same as Ctrl+W. However the same method can be used for both.
Recover from accidental Ctrl+U.
You can't undo these deletions. However, what you've typed is still in the .
register. You can confirm that (after pressing Esc to return to normal mode) with the command :reg
which will list all registers (or just :reg .
to display the .
register). You may be able to copy the missing text from the register display, for example, with the mouse.
Unfortunately, simply pasting the .
register won't help because it will repeat the Ctrl-u or Ctrl-w and will delete the text again. However, you can use another register (register a
in the following):
:let @a = @.
"aP
The above will paste all the text you last inserted, including what was accidentally deleted.
g-
andg+
, which AFAIK is not related to the use ofi_^W
.