Vi / Vim Quit Without Saving Command

I am a new vi / vim text editor user. How can I quit the vi / vim text editor without saving my changes to a file under Linux / Unix like operating systems?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time N/A
vi or vim is a text editor. You can use it to edit configuration files. Write programs in Perl, Python, C/C++, sh/bash/ksh and more. To exit or quite the vim/vi text editor without saving any changes press:
Let us see vi and vim commands in details.

How to quit the vi/vim editor without saving your changes

You can quit the vim or vi text editor without saving any changes you may have made to the file as follows:

  1. First, you need to press Esc key to get out of insert or append mode.
  2. Next type colon (: symbol)
  3. You see the cursor at the lower left corner of the screen.
  4. Finally, type the following command to quit without saving anything to a file:
Fig.01: Vim / vi text editor quit without saving changes command demo

Fig.01: Vim / vi text editor quit without saving changes command demo

This will force vi/vim to quit the editor, and all changes you have made to the document will be lost forever. You just discards any changes you made to the file.

Getting more info on how to use vim text editor

The vim or vi text editor has three modes. It has many commands and options for both new and advanced users. I strongly suggest that you start learning vim by typing the following command at the terminal:
$ vimtutor
Vimtutor starts the Vim tutor. Very useful for people working in IT, sysadmin jobs, and developers that want to learn their first Vim commands. Many commands works with vi too.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • The Brain Jun 22, 2013 @ 4:07

    Thank you!

  • mohamedabdallah Nov 17, 2013 @ 12:00


    • Sasha Jul 15, 2015 @ 1:33

      I believe that’s the opposite of “Vi / Vim: Quit Without Saving Command”

  • Korian Mar 19, 2015 @ 21:29


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum