.vimrcCourse
Vim
The text on the line, then a text object, an operator with a motion, the dot command, a register, and a global change.
- linetextitem latte = "oat"
6 lessons, in orderFree to read
Syllabus
Basics
The types, explained, then an object you can name and call.
-
01
Vim from zero: the text is the data
2 min read
A Vim buffer is text. w moves to the next word. On the line item latte = "oat", w from the start lands on latte.
item latte = "oat"latte -
02
A text object names a span of text. i" is the inside of the double quotes. di" on item latte = "oat" deletes oat and leaves the quotes.
Builds on lesson 1.
di"item latte = ""
Practice
A rule that prevents a bug, then a program that uses the object.
-
03
Vim from zero: an operator needs a motion
2 min read
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".
Builds on lessons 1 through 2.
dwlatte = "oat" -
04
The dot command repeats the last change. cwadd turns the word under the cursor into add. Dot on the next order line does it again.
Builds on lessons 1 through 3.
0cwadd<Esc> j0.add latte = "oat" add muffin = "warm"
Further
One more idea, then a program that puts the pieces together.
-
05
A yank copies text into a register. "ayi" on item latte = "oat" copies oat. "ap puts that note at the cursor. The register is the clipboard you can name.
Builds on lessons 1 through 4.
"ayi"oat -
06
:g runs a command on every line that matches. :g/^item /normal cwadd changes each order line that starts with item and a space. A note line stays.
Builds on lessons 1 through 5.
:g/^item /normal cwaddadd latte = "oat" note keep
Readings
Shorter pieces in the same language. Any order is fine once the lessons feel familiar.
-
Vim macros: a register full of keystrokes
2 min
GoByte Skills #27: a Vim macro is just keystrokes in a register. Record once with qa, paste it as text, edit it, yank it back, then run it on every line. The only program whose bug report reads: it did exactly what I did.
-
Vim's dot command: repeat any change
2 min
GoByte Skills #26: Vim remembers your last change as keystrokes, and . replays them at the cursor. Motions are not recorded, so shape the change to carry its own position: A, not $a. One key of automation, no YAML.
-
Vim operators and motions: a grammar
2 min
GoByte Skills #25: Vim commands are a verb plus a noun. d waits for a motion, 2w says how far, and every new motion works with every operator. Plus why cw breaks the pattern on purpose.