How to exit from vim


In this article, you will learn how to exit from vim. It is the most googled question.

Vim is a free and open-source, screen-based text editor program for Unix. It is an upgrade version of Bill Joy’s Vi. If you like free and open-source software, then this would be one of the first choices you would consider to start using Vim.

You can install Vim easily in any operating system but in Linux distribution with official software repositories as follow:

# apt-get install vim [On Debian/Ubuntu]
# yum install vim [On RHEL/CentOS]
# dnf install vim [Fedora 22+]

Vim is a neat and clean document. You can fill most of your answers to your question in its help system. Just using the :help command.

It’s also normally very fast and lightweight even when editing huge files of source code. It’s easy to run over ssh for remote operations on any server.

Get started with Vim. Simply type the commands in the terminal, then press i to switch to insert mode(insert text)

$ vim file.txt
OR
$ vi file.txt

There are various ways to exit vim editor. These are following :

  1. To exit Vi/Vim, use the **:q** command and hit **[Enter]**.
  2. To save a file and exit Vi/Vim simultaneously, use the **:wq** command and hit **[Enter]** or **:x** command.

Note: If you make changes to a file but try to quite Vi/Vim using **ESC** and **q** key, you’ll receive an error as shown in the screenshot below.

  1. To force this action, use **ESC** and:q!.

/media/insert-embed/dropbox

  1. Additionally, you can use shortcut methods. Press the **[Esc]** key and type **Shift + Z Z** to save and exit or type **Shift+ Z Q** to exit without saving the changes made to the file.

This is all about vim exit.


Share on social media

//