Vi / Vim: Wipe and Undo All Changes Since Opening a File

To wipe all changes and undo all modifications made to a file since it was opened in the vi or vim text editor, you can use the following command:

:e!

This command discards all changes and reloads the file from disk, effectively undoing all changes made since the file was opened.

Note: This will only work if the file has not been saved since the changes were made. If you have saved the file since making changes, you will not be able to undo those changes using this method.

Leave a Comment