Made a mistake while editing a file with Vim Donapost worry you can undo the changes in Vim and if you want you can redo the changes as well.
And itaposs pretty simple too. .
It cannot be simpler than this can it To remember u stands for undo and r stands for redo.
Letaposs go a bit in detail.
Vim maintains the record of changes in a stack in LIFO last in first out format. Whenever you make any change it gets added in the stack. When you undo it the last change gets undone first.
Letaposs take an example. I have this file where I have deleted line 3 and 6 in the same order.
To undo the changes I go to the command mode by pressing Esc key and then press the u key. As you can see it brings back the line number 6 first. Vim even shows the information about the undone change at the bottom.
News Link: https://linuxhandbook.com/undo-redo-vim/.