Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 36 ยท Modes and Navigation

Vim Marks, the Jump List and the Change List

Set marks with m, jump with ' and backtick, use global marks across files, and travel with Ctrl-o, Ctrl-i, g; and g, through the jump and change lists.

When you work in a large file you constantly leave a spot and need to come back. Vim has three built-in memory systems for this: marks you place by hand, the jump list it records automatically, and the change list that remembers where you edited. Using them replaces a lot of scrolling and searching.

Setting and using marks

A mark is a named position in a file.

  • ma sets mark a at the cursor (lowercase letters are local to the buffer).
  • `a (backtick a) jumps to the exact line and column of mark a.
  • 'a (apostrophe a) jumps to the first non-blank of the marked line.
  • :marks lists all marks; :delmarks a removes one.

Use the apostrophe for line-wise jumps and the backtick for precise ones. Both can follow an operator, and the difference mirrors the difference between line-wise and character-wise motions: d'a deletes whole lines from here to mark a, while d`a deletes only the text between the two positions.

A common pattern: set ma at the top of a block, scroll away to check something, then `a to return. Or select a region between two marks by hand with `a v `b.

Global marks

Uppercase marks A to Z work across files. mA in one file and then 'A from anywhere in Vim opens that file at that line. Think of them as bookmarks for your project: mM marks the main file, mT your test file. They are saved in the viminfo (Vim) or shada (Neovim) file, so they survive restarts.

Automatic marks

Vim keeps several special marks for you:

Mark Position
`. where you last changed text
`^ where you last left Insert mode
`" where you were when you last closed this file
`[ and `] start and end of the last change or yank
`< and `> start and end of the last Visual selection
`` (two backticks) the position before the latest jump

Two backticks (or two apostrophes) is the fastest "go back to where I just was" and toggles between two spots. This works because any big jump updates it.

The jump list

Vim records the position you leave when you perform certain jumps: G, gg, %, {, }, (, ), searches (/, n, *), H M L, 'x marks, : line numbers and tag jumps. Small moves like j and w are not jumps.

  • Ctrl-o goes to the previous position in the jump list ("older").
  • Ctrl-i (same as Tab) goes forward again.
  • :jumps shows the list; > marks where you are now.

If you search for a function name, read it, and want to return, press Ctrl-o. Press it repeatedly to retrace your path like a browser's back button. In Neovim the jump list is per window and persists via shada.

JS Jump list model (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Real Vim's list also deduplicates entries for the same line and holds up to 100; the model keeps the core idea, which is a path you can walk backward and forward.

The change list

Every edit position is recorded too:

  • g; jumps to the position of the previous change.
  • g, jumps to the next one.
  • :changes lists them.

This is perfect when you scrolled away after editing. Press g; and you are back at the last edit, and again for the one before. Combined with `. it makes "where was I working?" a two-key question. Neither list needs any setup, so they are friendlier than marks for casual use.

Tag-style jumps

Related navigation uses the same lists. Ctrl-] jumps to the tag (definition) under the cursor when you have a tags file or a language server, and Ctrl-t pops back along the tag stack. gf opens the file under the cursor and Ctrl-o (or Ctrl-^, which swaps with the alternate file) returns.

Ctrl-^ deserves its own mention: it toggles between the current and the previous buffer, which is the fastest way to flip between a source file and its test.

A marks table (stand-in)

The following block simulates mark storage with the local and global distinction and shows how a line-wise or character-wise jump would resolve. It is a model only.

JS Mark storage model (stand-in)

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command returns to the exact line and column of mark a?

    The backtick goes to the exact position; the apostrophe goes to the first non-blank of the marked line.
  2. 2. How do uppercase marks differ from lowercase ones?

    Uppercase marks are global and remember the file, so you can jump into it from anywhere.
  3. 3. What does Ctrl-o do in Normal mode?

    Ctrl-o walks backward through the jump list and Ctrl-i walks forward.
  4. 4. Which key jumps to the position of the previous change?

    g; goes to the previous change-list entry and g, to the next.

Summary

  • m{a-z} sets a local mark, m{A-Z} a global (cross-file) one; ` and ' jump to them.
  • Automatic marks such as `. and `` remember your last edit and your last jump.
  • Ctrl-o and Ctrl-i walk the jump list; g; and g, walk the change list.
  • Ctrl-^ flips between the current and the alternate file.
  • Both lists need no setup, so use them instead of scrolling.

Next: Visual Mode: Character, Line and Block Selection