How To Exit Vim Text Editor Command

Posted on in Categories , , , last updated May 23, 2017

I am a new Linux and Unix user. How do I exit the VIM or vi text editor on a Linux/Unix-like operating systems?

Vi or vim is a text editor for Linux and Unix-like operating systems. It can be used to edit all kinds of plain text files. It is especially useful for editing programs or system configuration files. The basic syntax is as follows to open a file using vim:

vim filenmame
vi filename

How to exit the VIM text editor

The procedure is as follows:

  1. First, you need to switch to command mode. This can be done by hitting the [Escape] key. Next, you can type the following commands:
  2. :q to quit.
  3. :q! to quit without saving data/file.
  4. :x save and quit.
  5. :qa to quit all open files.
  6. Please note that whenever you type :, a vim or vi : will appear at the bottom of the screen. You need to type the rest of the command at the bottom of the screen.

How to exit the Vim editor without saving

Example: How to exit vim editor in terminal (method #1)?

Press the [Escape] key.
Type :
Type q
Type [Enter] key

vim: How do I quit from Vi (method #2)?

You can press the [Escape] key.
Type SHIFT Z Z to save and exit.
OR
Type SHIFT Z Q to exit without saving.

Related media (Video) – Exit from the vim/vi text editor command

This tutorial is also available in a quick video format:



(Video 01: How to exit from the vim/vi text editor)

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+.

8 comment

  1. When I’m pissed of with something I’m like: Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc Esc :Q!

    And then the angrer level goes to the sky for pressing capital Q instead of the lowercase one…

Leave a Comment