![]() |
Vim (short for Vi Improvised) is a popular text editor mainly used in Linux and Unix-based operating systems but due to having a CLI (command line interface), it might be difficult for new users to make use of basic features such as undo in Vim. So in this article, we will learn different ways and types to undo changes in Vim Editor in Linux. Like all other modern text editors, Vim also has the functionality UNDO which enables the users to revert the changes done in the document. It saves the changes as revisions or entries in the memory so that when asked, it can revert the current revision to the previous revision.( basically undoing changes). Vim has also a criterion of what is to be considered an entry or revision. Any of the following can be considered an entry:
How to Undo in Vim Editor?Vim not only offers basic undo function, but also of various types with different affects. We can undo changes in three different ways:
Lets look at each of them one by one. 1. Undo Most Recent ChangeIn this method, we undo the last change we did on the document. In other words, we revert to the most recent revision of the document. Command u or :u or :undo To do this, follow the given steps:
![]() Before Undo
![]() After Undo 2. Undo Multiple ChangesWe can also undo multiple changes in a single command. Command Nu or :undo N where N is the number of changes you want to undo. Follow the given steps to do undo multiple changes in one go:
![]() Before Undo
![]() After Undo 3. Undo All Changes in a Single LineThis method allows the user to undo all the changes in a Single Line. Command U
Follow the given steps to undo all the changes in a Single Line:
![]() Before Undo
Listing All Undo BranchesAfter undo, we do some more changes and overwrite the last done changes with current changes. Generally, there is no way to access those removed changes but in Vim, these changes are not completely deleted but instead, their entries get branched into different undo branches. We can view and access these branches using the following command: :undolist
Example![]() Undolist ConclusionUndo is one of the basic operations in any text editor, and Vim has a powerful version of it that offers more capabilities as compared to other editors. This article discusses the different undo types in Vim, which can help you improve your productivity. |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |