Skip to main content
Vim Text Editor:

The Vim change list

Summary

Learn how to jump or move between change locations in Vim's change list — your edit history in Vim for the currently open file. This feature helps you move back and forth between changes in your editing history.

Introduction #

If you have ever wanted a quick way to jump to your most recent edits in Vim, the change list is a feature worth mastering. It allows you to move back and forth between changes in your editing history.

What is the change list in Vim? #

The change list is a feature in Vim that keeps a record of the positions in the current buffer where you have made edits.

Each time you make a change — whether you insert, delete, or modify text — Vim stores the cursor position at the time of the change in a list specific to that buffer.

If you switch between files (buffers), each buffer has its own change list that tracks the local edit history.

Change list resets when you close a buffer! Changes are not persistent across sessions.

Unlike the undo tree, which records the actual changes made to the content, the change list only remembers the locations of changes. This allows you to jump directly to the locations where you made recent modifications without altering the content.

How the change list works #

Here are a few things you should understand about how the change list functions:

  1. Each buffer has its own independent change list.
  2. Only the most recent 1000 changes are stored (this can vary based on configuration).
  3. Moving the cursor manually does not affect the change list; only edits do.
  4. Using commands like :normal, :s, or macros can also update the change list if they cause changes.

It is important to note that change list navigation does not alter the content of your file. It merely moves the cursor to different change positions.

Viewing the change list #

To view the change list, type the following in normal mode:

:changes

This displays the list of recent change locations. Similar to :jumps, the current position in the change list is marked with a > symbol.

Example:

 change line  col file/text
>    1   100   6 
     2    90   3
     3    45   8

Use, e.g. 3g; to go back to change 3 from the list.

To move through the change list, Vim provides two dedicated commands:

  • g; — Go to the previous change position.
  • g, — Go to the next (more recent) change position.
  • <number>g; — Go to the n-th change position.

These commands allow you to quickly revisit areas where changes were made, regardless of the file’s current scroll position.

For example, if you edited line 10, then line 50, and then line 100, pressing g; would take you from line 100 back to line 50, and another g; would bring you to line 10.

Difference between change list and undo history #

The change list should not be confused with the undo history in Vim. While both relate to changes made in a file, they serve different purposes:

  • The change list tracks where changes were made.
  • The undo tree (accessed with u and <Ctrl-r>) tracks what changes were made and allows you to reverse or redo them.

You can combine both features to navigate and manipulate changes. For example, use g; to jump to a recent change location and then press u to undo the change at that location.

Difference between jump list and change list #

While both the jump list and change list are used to keep track of cursor positions, they serve different purposes:

  1. The jump list keeps track of cursor movements to different locations.
  2. The change list keeps track of edits or changes made to the text.

To navigate the jump list, you use:

  1. Ctrl-o to move backward through the jump list.
  2. Ctrl-i to move forward through the jump list.

If you are editing a file and want to revisit places where you made changes, use the change list. If you want to revisit locations you navigated to, use the jump list.

FAQ's #

Most common questions and brief, easy-to-understand answers on the topic:

What is a change list in Vim?

A change list in Vim is a record of all positions in a file where changes have been made, allowing you to jump between those points quickly.

How do I move through the change list in Vim?

You can use g; to go to the previous change and g, to go to the next change in the change list.

Does the change list track all changes?

Yes, the change list keeps track of all changes made in a buffer during a session, including insertions and deletions.

Is the change list the same as the undo history?

No, the change list tracks cursor positions of edits, while undo history tracks the actual content changes.

Can I customize change list behavior in Vim?

The change list behavior itself is not configurable, but you can combine it with other commands and mappings for enhanced workflows.

Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

The Vim change list by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/vim-change-list">The Vim change list</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the Ditig legal page.

All Topics

Random Quote

“Less is more.”

Ludwig Mies van der Rohe German architect and designerWord of mouth, - IT quotes