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

How do I reset the jump list to start fresh in the current window?

Answer

:clearjumps

Explanation

The :clearjumps command wipes the jump list for the current window, giving you a clean slate for <C-o> and <C-i> navigation. This is useful when you have been jumping around a large codebase and want to start a focused session without wading through stale positions.

How it works

Vim maintains a per-window jump list that records every time you move more than a few lines or open a new file. The list can hold up to 100 entries. Over a long session the list fills with positions that are no longer relevant.

  • :clearjumps — empties the jump list for the current window only
  • After running it, <C-o> (jump back) and <C-i> (jump forward) have no history to traverse
  • The change list (navigated with g; and g,) is not affected

Example

Before clearing, :jumps might show:

 jump line  col file/text
   3   142    0 src/main.go
   2    87    4 src/utils.go
   1    12    0 README.md
>

After :clearjumps:

 jump line  col file/text
>

Tips

  • Use :jumps to inspect the jump list before and after
  • This affects only the window where you run it; other windows retain their lists
  • Neovim users can also clear via the API: vim.api.nvim_buf_call(0, function() vim.cmd('clearjumps') end)
  • To see the change list (unaffected by this command), use :changes

Next

How do I run a shell command on a range of lines in normal mode and replace them with the output?