Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM:: Undo changes on or around the specified text

Tags:

vim

undo-redo

In VIM is it possible to undo changes on or around a specific block of text? Lets say I make change A right above "if yes", then do changes B, C, D and E in other places on the file. Is it possible to tell vim "undo changes that were done with in +/- 10 lines from if yes?

I've come across another question that suggest this isn't possible, or at least in vanilla vim. Does any know of any plugins that would allow for this behavior?

like image 591
Diego Avatar asked Dec 10 '22 09:12

Diego


1 Answers

@Zsolt's answer is probably very interesting, I'd have to get acquainted with that.

What I usually do is, doing something like

100g- (go back to history snapshot that contained the thing you want to restore)

yank your 'rescue' text using some method, e.g.

:12,17yank

999g+ (return to the tip of history)

use regular edit actions to restore the yanked lines into place.

like image 157
sehe Avatar answered Jan 28 '23 18:01

sehe