undotree icon indicating copy to clipboard operation
undotree copied to clipboard

Feature request: Search through undo history

Open juancampa opened this issue 10 years ago • 9 comments

I have found myself in this situation many times.

It would be awesome to be able to search through the undo history to find exactly where a particular string of text was added/removed.

juancampa avatar Dec 31 '14 21:12 juancampa

Looks like it should be vim rather than undotree who provide this kind of ability because the undotree is just a 'better user interface' for the cumbersome VIM commands and all the undo/redo data is maintained by VIM internally. What I could think of is a simple workaround like this // pseudo code loop until undo is not available { search "the string" undo one step. } map the script to something like a command or hotkey and it should do the job. It can even work without undotree.vim, but if you leave the undotree open, it will update itself according to the main content.

mbbill avatar Jan 04 '15 03:01 mbbill

I think this would be a nice feature. I've been in some situations were this would be helpful. I agree that the workaround proposed by @mbbill is probably the only solution. The integration with the plugin would allow to highlight all the previous versions containing the string on the undotree window (maybe using :match Visual /pat/).

mMontu avatar Jan 14 '15 17:01 mMontu

+1. I've asked about this before (http://vi.stackexchange.com/q/2220/1060 has links to both a SuperUser.com question and a Gundo feature request). I may switch to undotree from Gundo anyway, but if this were implemented I'd switch immediately.

BatmanAoD avatar Feb 25 '15 20:02 BatmanAoD

Mundo has this feature but it requires Python like Gundo.

esamattis avatar Oct 24 '16 18:10 esamattis

I'm think of a major refactor for Vim8 and NeoVim to take advantage of the async jobs. Maybe this feature can be implemented too. But it's not happening soon because I'm pretty busy now :(.

mbbill avatar Oct 25 '16 02:10 mbbill

yes please! any news on this?

dagadbm avatar Nov 15 '19 17:11 dagadbm

I think this would be a very useful feature as well. It's supported natively by Mundo.

The problem with the solution provided above is that stepping through the changesets in the history modifies the buffer, and in itself changes the history even as we are searching it. Which is really not nice.

Conceptually, to me this feature belongs in the domain of the extended undo interface rather than being done in Vim. The whole purpose of the undo extension is to abstract out the change history and operate/navigate it in better ways. Searching for a particular undo/change is part of that.

jeetsukumaran avatar Nov 02 '21 18:11 jeetsukumaran

Implemented a working but slow version of search. check out this branch https://github.com/mbbill/undotree/tree/search

mbbill avatar Nov 06 '21 03:11 mbbill

Nice! It works fine enough for me :) THANKS!

jeetsukumaran avatar Nov 06 '21 08:11 jeetsukumaran