How do I delete characters, words, and lines without leaving insert mode?
Answer
<C-h> / <C-w> / <C-u>
Explanation
Vim provides three levels of deletion directly in insert mode, so you don't need to switch to normal mode for small corrections.
The three levels
| Keystroke | Deletes |
|---|---|
<C-h> |
One character backward (same as Backspace) |
<C-w> |
One word backward |
<C-u> |
Everything from cursor to the start of the line |
How they work
<C-w> deletes backward to the start of the previous word:
Before: The quick brown fox█
<C-w>: The quick brown █
<C-w>: The quick █
<C-u> deletes everything you typed on the current line since entering insert mode:
Before: function processData(input) {█
<C-u>: █
Why this matters
These three keystrokes eliminate the most common reason to leave insert mode — fixing a typo:
- Mistyped a character?
<C-h>(don't reach for Backspace) - Mistyped a word?
<C-w>(don't escape,daw,i) - Wrong entire line?
<C-u>(don't escape,dd,O)
Tips
<C-w>and<C-u>also work in the command line (:prompt) and search (/prompt)- These are actually terminal shortcuts, not Vim-specific — they work in bash, zsh, and most Unix programs
<C-w>respects theiskeywordoption for word boundaries<C-u>only deletes text entered during the current insert session, not text that was already there- These keystrokes are significantly faster than switching to normal mode for small edits