12

Is there an easier way to find a particular change in Vim's undo tree than just looking at random old versions of the file one at a time (either using vanilla VIM commands, Gundo, or another plugin)?

Ideally, I'd like to enter a search pattern to be matched against all of the diffs shown in the preview pane by Gundo, and then have Gundo show me which versions have diffs that match that search.

This question asks something almost identical, but the asker has accepted an answer that simply recommends Gundo, which, wonderful though it is, doesn't appear to do what I'm asking for.

I have pitched this as a new feature for Gundo, but received no response.

EDIT: There is an open request for this feature for undotree.

NOTE: This question has been "manually migrated" from superuser.

Kyle Strand
  • 649
  • 3
  • 18

2 Answers2

6

In some cases, this might be enough:

:changes

Unfortunately it doesn't show a complete summary of your editing history. It appears to show only the line of text which you landed on after each change.

That is good enough to display all single-line inserts or edits, but only the last line of a multi-line insert, and no deleted text.

It can only be searched visually, not automatically, although you could grab this command and then do:

:PipeCmd changes | less

which would allow searching with /. Or just pipe to grep instead of less.

An alternative way to search that list would be to install the Unite plugin and then do:

:Unite change
joeytwiddle
  • 3,622
  • 19
  • 28
  • 1
    Hm. Since doing a search-and-replace can make the word(s) being replaced completely invisible to changes, that's not terribly useful. What I'd really like is to be able to do :%s/foo/bar/g, then do a search for foo that would (reconstruct and) show me the last version of the file in which foo was present. – Kyle Strand Feb 26 '15 at 18:42
3

There is now a gundo fork called "mundo" with this feature.

While in the undo-tree window, / will search the history rather than the text displayed in the window itself.

(Note: this feature appears to have been adopted from a different gundo fork. I'm not sure where credit for the implementation belongs, and I have not tried both forks to see which one works better.)

Kyle Strand
  • 649
  • 3
  • 18