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

How do I delete everything typed on the current line without leaving insert mode?

Answer

<C-u> in insert mode

Explanation

Pressing <C-u> while in insert mode deletes all characters entered since you last entered insert mode on the current line. This is a fast way to "start over" on a line when you realize what you're typing is wrong — no need to escape, undo, and reenter insert mode.

How it works

  • <C-u> deletes backward to the start of the text entered in the current insert session on the current line
  • If no text has been entered yet (e.g. you pressed A on an empty line), it deletes back to the first non-blank character or the very beginning of the line
  • The deleted text is not saved to a register — it is gone, though u (undo) in normal mode will restore it
  • Works in all insert-mode entry points: i, a, I, A, o, O, c, s, etc.

Example

You press A to append at the end of a line and type a long string:

foo_function_with_a_typo_|

Rather than backspacing character by character, press <C-u> to erase everything you just typed, leaving:

|

The cursor is now at the start of the line (or back to where insert mode was entered), ready for you to retype.

Tips

  • Companion command <C-w> deletes one word backward at a time while staying in insert mode
  • <C-h> is the insert-mode equivalent of <BS> (delete one character)
  • These shell-style <C-u> and <C-w> bindings carry over from readline/terminal — they feel natural if you're used to shell editing

Next

How do I open just enough folds to see the current line without expanding everything?