Vim is kind and remembers the locations you have recently visited. In your :jump and :changes list, you can see your history just like in browser. This list contains all location where you jumped from. Just like in a browser, each window has its own jump list.

For example searching, substitute, and marks are jumps, however scrolling does not count as jump. A good “go to definition” lsp implementation works the same way, but sadly not all does this and it can annoying.

Jumps

  • ^o: Jump back in history.
  • ^i: Jump forward in history.

So for example, if you are using vim-go and you call :GoDef, you will end up somewhere else in your codebase, but if you want to go back where you were before the jump, just press ^o (Ctrl + o).

As I mentioned above, we can list our jump list with :jump, the format is simple (as stated in the header of the output). A single > character at the beginning of the line marks your current location. The current position is always jump 0 and the counter goes up on both sides.

:jumps
   1     1    0 # Jumps
>  0     4   17 `:jump` list, you can see your history just like in browser. This list contains
   1    15    6 * `C-i`: Jump forward in history.

This list can be very long and pressing ^o 20 times sounds like something we shouldn’t do, and yes we shouldn’t do that, we can add a [count] before jump, so if we want to jump back 20 locations, we can use 20^o.

Edit locations

There is a special “jump list” called “change list”, it marks all changes you made in a file. A single “insert mode session” counts as one change. We can list changes with :changes, it has a similar format, but instead of a filename, it shows the content of the line.

  • g;: Jump back in history.
  • g,: Jump forward in history.