explaingit

mbbill/undotree

4,530Vim ScriptAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A Vim plugin that shows your full edit history as a visual branching tree, so you can jump to any past version of your file, not just undo in a straight line.

Mindmap

mindmap
  root((undotree))
    What it does
      Visual undo tree
      Branch navigation
      Timestamp display
    Tech Stack
      Vim Script
      Vim plugin
    Use Cases
      Recover old edits
      Compare versions
    Features
      Persistent undo
      Key reference panel
      Save markers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

View and navigate your full branching undo history in Vim from a side panel without losing any edits

USE CASE 2

Jump back to a version from an hour ago without losing other changes you made since

USE CASE 3

See at a glance which states existed when you last saved the file using visual markers

Tech stack

Vim ScriptVim

Getting it running

Difficulty · easy Time to first run · 5min
Use, modify, and distribute freely for any purpose including commercial use, as long as you keep the copyright notice.

In plain English

Undotree is a plugin for Vim, a text editor used heavily by developers, that visualizes how your edit history is structured. Most editors store undo history as a straight line: you can go back and forward through changes in order. Vim works differently. It stores every change as a branching tree, so if you undo back to an earlier point and then make a new edit, you do not lose the version you just moved away from. Undotree draws that tree in a side panel so you can see the shape of your history and jump to any point in it. The panel shows each change with a sequence number and a timestamp. Markers indicate which state you are currently on, which one would be restored if you pressed redo, which is the most recent change, and which states were present when you last saved the file. Pressing the question mark key inside the panel shows a quick reference of navigation keys. The plugin does not write anything to disk on its own and does not risk data loss. Moving through the undo tree modifies the open file buffer temporarily, the same way autocomplete suggestions do, and any state you visit can be visited or left without consequences. The README also explains Vim's built-in persistent undo feature, which is separate from this plugin but often used alongside it. Persistent undo lets Vim save the undo tree to a file so your history survives closing and reopening a session. The README includes a configuration snippet for storing those undo files in a dedicated folder. Installing undotree follows the standard pattern for Vim plugins and works with common plugin managers like Vim-Plug or Vundle, or with Vim's built-in package system. The plugin is written entirely in Vim Script, licensed under BSD.

Copy-paste prompts

Prompt 1
I have undotree installed in Vim. How do I open the panel and navigate to a specific past version of my file?
Prompt 2
Show me how to configure Vim's persistent undo so my undo history survives closing and reopening Vim sessions, with undotree files stored in a dedicated folder
Prompt 3
What do the different markers in the undotree panel mean, the current state, redo state, and last-save state?
Prompt 4
How do I install undotree using Vim-Plug and set a keyboard shortcut to toggle the undo tree panel?
Open on GitHub → Explain another repo

← mbbill on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.