VIM :: Undo changes on or around the specified text

In VIM, you can undo changes on a specific block of text or around it? Suppose I make changes to A directly above "if yes" , then make changes to B, C, D, and E elsewhere in the file. Is it possible to tell vim "to cancel changes that were made with +/- 10 lines from if yes ?

I came across another question that suggests this is not possible, or at least in vanilla vim. Does anyone know of any plugins that would allow this behavior?

+4
source share
2 answers

With this plugin: http://www.vim.org/scripts/script.php?script_id=3304 you can easily navigate the undo tree.

  • So, go back to the original section (near if yes ), mark it ma ,
  • Let's go back to the previous state on the tree (even if it cancels other changes).
  • Copy (yank) the area you want to keep in the register (for example, select the visual lines - V5j"by ).
  • Return to the actual state (last element of the Gundo tree).
  • Go back to the section you want to change ( 'a )
  • The section you want to return has been deleted and replace it with the contents of register b .
+4
source
Answer to

@Zsolt is probably very interesting, I would have to meet him.

What I usually do is something like

100g- (return to the history snapshot containing the item you want to restore)

keep the text "salvation" using some method, for example

 :12,17yank 

999g + (return to the end of the story)

Use regular editing actions to restore drawn lines.

+10
source

Source: https://habr.com/ru/post/1347146/


All Articles