vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump to the previous change and reveal it clearly in Vim?

Answer

g;zvzz

Explanation

Jumping through the changelist with g; is useful, but in real files the destination can land inside a closed fold or off-center on screen, which slows review. Chaining g; with zvzz turns it into a practical navigation primitive: jump to the previous edit, open folds just enough to show it, then center the context. This is especially effective when auditing refactors across large files.

How it works

g;zvzz
  • g; moves to an older entry in the changelist
  • zv opens folds needed to make the current line visible
  • zz centers the cursor line in the window

Example

Imagine you touched several distant functions during a cleanup pass. Instead of repeatedly searching, run g;zvzz to walk backward through edit points with the right context each time.

change 1 -> change 2 -> change 3

Each jump lands on an actual edit location, unfolded and centered, so you can inspect quickly and decide whether additional fixes are needed.

Tips

  • Use g, with the same suffix (g,zvzz) to walk forward through the changelist
  • Pair with :changes when you want a full indexed list before jumping

Next

How do I mix very-nomagic and magic sections in a single Vim search?