Vim Undo and Redo Operations
While editing text files with vim we can make some little mistakes or want to revert to the previous states. In Microsoft Word there is features rich undo and revert functions. The similar undo and revert functionalities provided by vim too.
In order to revert back we can list changes and related information. With the
:undolist command we will list number of changes and time information. We will get following information.
- Change number
- Change Time
- Is saved
Undo Only Last Change
While writing text or developing applications we generally made a lot of change in the file. At some point we can see that there is mistakes or we should return to the previous versions of file. We can use
u shortcut to revert or undo last change. We can use
u multiple times which will go previous versions step by step.
Redo Changes which Undo
So while going back to the previous versions we noticed that we have to to forward . As vim stores changes in a structural way we can return new versions or redo with the following command.
Return To The Original Versions
If we are sure and want to go first versions we can use following command.
Revert Specified Number Of Change Earlier
Reverting back one by one is a trivial task. As we see in previous examples we can list undo list. We can use one of the intermediate steps to revert back. In this example we will revert 5 steps back.
Revert Specified Number Of Change Later
We can also revert to the forward which means we will go to the latest changes. In this example we will revert to later 10 steps with the following command.