Step 2 of 5

15. The Changelist Jumplist And Tag Stack

The changelist

The changelist keeps track of the position of every change that happens in the buffer. When you make a change, the position of the cursor is remembered in the changelist so that we can return to it later.

This is quite similar to the ". mark — but instead of only keeping track of the last change that was made, it keeps track of the whole history of changes. This means we can jump back multiple changes if we want!

The command for jumping backwards in the changelist is g;. Hitting g; just once has the same effect of jumping to the ". mark with `.. But if you hit it again, you’ll notice that it takes you to the change before that. Another hit will take you to the change before that, and so on.

We can also move forward in the changelist with g,, which just moves us in the opposite direction to g;.

Both of these commands take counts, so you can type 10g; to jump ten changes backwards, for example.

Final note: the changelist is buffer local, so you can’t use it to jump between files.

The document in the editor has three typos hiding in it. The checklist below has you fix each one, then use g; and g, to hop back and forth between the places you just edited — no marks required.

  1. Delete the stray q on line 3 3G puts you on the line — move onto the q at the end ($ gets you there) and press x.
  2. Fix the doubled letter on line 12 12G, put your cursor on the extra e in Theree, and press x.
  3. Remove the extra period on line 21 21G, then $ to reach the end of the line, then x.
  4. Jump back to the top Watch where the next commands take you from here — first, return to the top with gg.
  5. Step back through the changelist with g; One press takes you to the newest change, on line 21.
  6. Press g; again This is the bit marks can't do — you land on the change before that, on line 12.
  7. And once more Back to the very first change, on line 3.
  8. Step forward again with g, g, walks the other way — forward to the change on line 12.
Delete the stray q on line 3 3G puts you on the line — move onto the q at the end ($ gets you there) and press x.

Next: Fix the doubled letter on line 12

Loading editor…