Edit a whole word

0 of 6

The technique

Your textVim mode: Normal
Change draft to final. The cursor is in the middle of the word. Before: Send the draft report.. After: Send the final report..

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.

Guides on this topic

Exercise 1 of 6

0keys

par 9

This setting is called theme now. Rename color to theme.

Your textVim mode: Normal

Make it look like this

// Settings the storefront reads when it starts.
export const settings = {
  currency: "EUR",
  pageSize: 24,
  theme: "dark",
  showReviews: true,
  supportEmail: "help@northwind.shop",
};

Yours

Par

Keyboard shortcuts
Ctrl+Enter
Check the result
Ctrl+Alt+U
Undo the last change
Ctrl+Alt+H
Show the next hint
Ctrl+Alt+R
Start the exercise over
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Ctrl+Alt+K⌃⌥K
Show the keyboard shortcuts
Ctrl+Alt+F⌃⌥F
Turn focus mode on or off
Ctrl+Alt+S⌃⌥S
Open the editor settings
Enter
Go on to the next step after you finish

The Ctrl+Alt shortcuts don't clash with Vim's own keys. On a Mac, use Control and Option.