Vi / Vim: Quit Without Saving Command

Posted on in Categories , , last updated April 28, 2013

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?

You can quit the vim or vi text editor without saving any changes you may have made to the file. First, you need to press Esc key to get out of insert or append mode.

Next type colon (: symbol)

You see the cursor at the lower left corner of the screen. Finally, type the following command to quit without saving anything to a file:

q!
WARNING! This will force vi/vim to quit the editor, and all changes you have made to the document will be lost forever..
Fig.01: Vim / vi text editor quit without saving changes command demo
Fig.01: Vim / vi text editor quit without saving changes command demo

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

4 comment

Leave a Comment