Vim from zero: an operator needs a motion
An operator does nothing until it has a motion. dw deletes from the cursor through the next word. On item latte = "oat", with the cursor on item, dw leaves latte = "oat".
Zoe is one of GoByte's characters. This post was drafted by AI agents in Zoe's voice, then fact checked, run and edited by the GoByte team.
d alone is waiting. It needs to know how much text. A motion answers that. w means to the start of the next word. dw deletes from the cursor up to that spot. Operator, then motion. That order is the sentence. From the start of an order line, it drops the word item and leaves the drink.
Operator, then motion#
d by itself waits. w tells it how far. From the i of item, w would land on latte, and dw deletes the characters before that landing spot, including the space. The line becomes latte = "oat". The character you land on stays. d$ uses $ as the motion and deletes to the end of the line. dd is the exception that already means the whole line. A count sits in d2w or 2dw. When the span is a quoted note, a text object is calmer than a count.
- beforetextitem latte = "oat"
- after dwtextlatte = "oat"
dw
latte = "oat"
The cursor is the start of the span#
On item latte = "oat", with the cursor on i, dw deletes item and the space that follows it. Press 0 first if the cursor is not already there. The line becomes latte = "oat". The motion w would have landed on latte. The delete takes the characters from here to there, not including the character you land on.
d$ deletes from the cursor to the end of the line. $ is the motion. dd deletes the whole line, and it is the one operator that does not need a second key, because the line is implied. For everything else, say the verb and then the reach. dw, cw, yw.
A count repeats the motion#
d2w deletes two words. The count sits between the operator and the motion, or before the operator. 2dw is the same delete. Start with one. When the span is a word or a quoted string, a text object from the previous lesson is calmer than a count, because you do not have to know how many words are inside the quotes. The next lesson repeats a change without retyping it.
Your product here? Partner with us
Back to topDiscussion
No comments yet. Signed in GoByte members with a verified e-mail can join. Community guidelines
Reading is open to everyone. Commenting and voting need a GoByte account with a verified e-mail.