How to Exit Vim Editor?

In this article you will learn how to exit vim editor with and without saving.

What is Vim?

Vim is a text editor that is highly cofigurable and customizable. It was written by Bram Moolenaar and was first released publicly in 1991. It is used to create, open, read, write, delete text files. It is preinstalled in Unix, Linux OS like Ubuntu and MacOS. Vim is commonly called as Vi editor or programmer’s editor. It is a freeware and available for Windows, Unix, MacOS, Linux. Vi editor is an efficient editor compared to other text editors and is being continuously provided with new features. It includes plugin support which makes it a powerful tool for text editing of files of various formats. It supports almost all text formats and programming language files.

One of the most important feature it provides is the multi level undo operation by which we can perform undo as many times as we want to which is restricted by a single undo in the Windows default text editor Notepad. It provides all the functionalities provided by gedit text editor which is the default text editor in Unix and Linux systems. Vi editor can be used as both a Command Line interface or GUI (Graphical User Interface) Standalone Application. Vim is commonly used for writing script programs. Vi editor has a lot of help options given in its manual which can be accessed by using command “man vi” in Terminal.

This is a simple while loop in Vim script :-

let a = 0
while a < 10
  echo "count is" a
  let a += 1

A common problem faced by many programmers is they face difficulties to quit vim editor or find it cumbersome. So here are some commands listed in which you can use to quit vim editor easily.

How to Exit Vim Editor?

Press Esc key. Once you have done that, vim goes into command mode. Then to exit the editor type anyone of the following commands.

:q – quit vim editor without saving your opened file

:q! – quit without saving and is used to quit when no save operation is performed

:wq – write and quit after saving changes

:wq! – write and quit even if file has only read permission (it can be thought as force quit)

😡 – write and quit. It is similar to :wq! But it does not commit changes if no modification in the file contents is done

:qa – quit all

See below screenshot as an example.

How to Exit Vim Editor

With the help of these commands you can easily exit vim editor without facing any difficulties as these are the easiest way possible to quit vim editor.

Leave a Comment

Your email address will not be published. Required fields are marked *