≡ Menu

How To Exit Vim Text Editor Command

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

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

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)

Share this tutorial on:
{ 6 comments… add one }
  • aref ghobadi August 17, 2015, 9:50 am

    Hi
    thanks

  • suyash November 9, 2015, 7:27 am

    simple :)

    • yahza December 9, 2015, 2:09 pm

      doesn’t seem to b working

  • Red Panda April 24, 2016, 8:48 pm

    I love you man thanks for this I searched loads of places and this was the clearest

  • Spiros M. June 29, 2016, 4:01 pm

    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…

  • Emmanuel August 4, 2016, 6:39 pm

    Thanks. Pretty clear and straight to the point.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , ,