Learn Vim / How to Delete a Character in Vim

How to Delete a Character in Vim

The answerMove the cursor onto the character and press x in normal mode.

Try it on a real buffer

Line 2 has a typo: “commannd” has an extra n. Move onto the extra “n” with h j k l and press x to delete it.

Vim rewards precise, tiny edits.
Every keystroke is a commannd.
Trust the home row.

Canonical solution: j, move onto the extra n, x · par: 4 keystrokes (vimgolf rules — every keypress counts).

Why it works

h ← · j ↓ · k ↑ · l → — keep your fingers on the home row. x deletes the character under the cursor. Arrow keys work too, but you're here to break that habit.

Variations

KeysWhat it does
xdelete the character under the cursor
Xdelete the character before the cursor
5xdelete five characters
r{char}replace the character instead of deleting it

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “The stray key” mission takes about a minute.

Practice free — no signup →

Keep going