Edit a whole word
The technique
ciw takes the whole word, wherever the cursor is in it. cw from the same spot would leave dr behind.
Keys in this lesson
- ciw
- Change the word under the cursor.
- diw
- Delete the word, not the spaces.
- daw
- Delete the word and one space.
Before you begin
Use h, j, k, l to move in Normal mode. Esc stops inserting and u undoes an edit. 0 goes to the start of the line and 2G goes to line 2. A count repeats a movement, so 3l moves three characters right.
More about this lesson
Change or delete a whole word from anywhere inside it.
c changes some text and puts you in Insert mode. d deletes it and keeps you in Normal mode. iw means the whole word, wherever your cursor is in it. Letters, digits and underscores all count as part of a word. aw also takes one space next to the word.
Change a word
tax = Math.round(total) → tax = Math.ceil(total)
From anywhere in “round”, ciw, then ceil, then Esc changes the whole word. cw from the middle would leave the start of the word behind. When you move down with j, you often land in the middle of a word, and that's where ciw helps.
Delete a word and its space
send the the invoice → send the invoice
From anywhere in either “the”, daw removes the word and the space after it. At the end of a line or before punctuation, where there's no space after the word, it takes the space before it.
diw deletes just the word and leaves both spaces. You'll mostly want ciw to replace a word or daw to remove one.