Vim course Lesson 1 of 6

Vim from zero: the text is the data

A Vim buffer is text. w moves to the next word. On the line item latte = "oat", w from the start lands on latte.

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.

Back to top

Vim does not edit a mysterious structure. It edits the characters in the buffer. An order is a line of those characters. A word is a run of them. w moves the cursor to the start of the next word. The move is the first half of every later command. You have to be on the drink before you can change it.

The buffer is characters, and w points at a word#

The line item latte = "oat" is an order: a kind of line, a drink, and a note in quotes. It is characters in a buffer, not a syntax tree Vim will protect for you. w is a motion. From the start of the line, it advances the cursor to the start of the next word, latte, and the characters stay where they were. The output of this lesson is that word, so you can see what the motion pointed at. A word ends at whitespace, with punctuation depending on 'iskeyword'. Watch the cursor. If it sits on the character you meant, the motion is right.

w moves onto the drink and changes nothing
  1. beforecursoritem
  2. after wcursorlatte
item latte = "oat"
latte

w lands on the next word#

Put the cursor on the i of item. Press 0 if you are not sure you are at the start, then press w. The cursor is now on the l of latte. The line did not change. Only the cursor moved. The sample's second block is that word, the drink, so you can see what w selected as "here."

A word, for this motion, ends at a space or at punctuation, depending on the character. latte is a word. "oat" starts at the quote. Press w again and you leave latte for the =, or for the quote, based on how your 'iskeyword' is set. Watch the cursor. The motion is correct when it sits on the character you meant.

The line is still the line#

Nothing in this lesson deletes or inserts. If the buffer changed, a different command ran. w is a motion. Motions are how you point. The next lesson is a text object, which points at the inside of the quotes without you counting characters.

Report a mistake

Your product here? Partner with us

Back to top

Discussion

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.