Quit Without Saving In Vim/Vi

Vim or Vi is a command-line text editor which is mainly managed with the commands and key shortcuts. After making changes in a file you may want to quit or exit from Vim. In this tutorial, we will learn how to quit from Vim or Vi without saving changes.

Open and Make Changes In Vim

First we will open a file named sample.txt with the Vim like below.

$ vim sample.txt

Quit Without Saving Changes From Vim/Vi

After making some changes we may want to quit. But there is a question we should answer the question “Will we save the changes?”. For this case we will not save the changes and exit. We will follow these steps.

  • Press the ESC key in order to change normal mode.
  • Type :quit! or :q! which will quit without saving. The q! is the short form of the quit! .

But keep in mind that all changes will be lost forever. You can not revert back in any way.

READ  Where Are .vimrc and vimrc Files?

Leave a Comment