Learn Vim / How to Change a Word in Vim

How to Change a Word in Vim

The answerWith the cursor anywhere on the word, press ciw — the word vanishes and you're in insert mode. Type the new word, press Esc.

Try it on a real buffer

The review wasn't that bad. Put the cursor anywhere on “terrible” and press ciw — change inner word — then type wonderful and Esc.

The code review was terrible.

Canonical solution: ciw wonderful Esc · par: 14 keystrokes (vimgolf rules — every keypress counts).

Why it works

c is the change operator: delete + enter insert mode. ciw works from anywhere inside the word — no need to be at its start. Compare with cw, which changes from the cursor onward.

Variations

KeysWhat it does
ciwchange inner word (from anywhere in it)
cwchange from the cursor to the end of the word
cawchange the word plus its space
Cchange to the end of the line

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

Practice free — no signup →

Keep going