Replace a Character

r{c} โ€” overwrite one character without entering insert mode.

Keys: r

r{c} replaces the character under the cursor with {c} and stays in normal mode. Perfect for fixing a typo without a iโ€ฆEsc dance.

Typo? Cursor on the wrong letter? r{c} swaps it for {c} and leaves you in normal mode. No insert mode round-trip, no Esc. One change, one keystroke past the new character.

Replace the character under cursor with x
KeyNote
r
x
Replace the next 3 characters with ---
KeyNote
3
r
-
r{c} โ€” replace one character

Reference

Key Action
r{c} Replace one character with {c}
{n}r{c} Replace next {n} characters with {c} (repeated)
rEnter Replace with a newline (split line)
R Enter replace mode (continuous overwrite)
gr{c} Replace virtually (don't extend short lines)

Worked example โ€” r x

Replace one character without entering Insert.

Step 1 ยท
editing.replace-char
Step 2 ยท rx ยท rx โ€” 'f' becomes 'x'.
rx โ€” 'f' becomes 'x'.

r waits for the next keystroke and writes that char in place. No mode change. R enters Replace mode for many chars.

See also: Replace Mode, Change