Learn Vim / How to Replace a Single Character in Vim

How to Replace a Single Character in Vim

The answerMove onto the character and press r followed by the new character — no insert mode needed.

Try it on a real buffer

“biat” should be “boat”. Put the cursor on the wrong letter and press r followed by o — replace a single character without ever entering insert mode.

i live on a huge biat on the river

Canonical solution: move onto the i in biat, then r o · par: 5 keystrokes (vimgolf rules — every keypress counts).

Why it works

r{char} swaps exactly one character and leaves you in normal mode. For longer overwrites, R enters replace mode (like classic “overtype”).

Variations

KeysWhat it does
r{char}replace one character
Rreplace mode — overtype until Esc
~toggle the case of the character

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “One-letter fix” mission takes about a minute.

Practice free — no signup →

Keep going