How to Exit Vim: 3 Essential Ways to Exit Vim / Vi

If you are feeling quite bad because you failed on how to exit vim, then please don’t. Because you are not alone, as over a million developers globally have searched “How to exit vim?”, “How to Exit Vim Editor?”, “How to quit Vim?”, “How to save & quit Vim?” etc according to Stack Overflow blog.

Also Read: 5 Best Linux Gaming Distros

The global complexity might look surprising because even with the conveniently displayed information on how to exit vim can be seen on the splash screen. But it seems like one does not simply “Exit Vim”.

In this article let’s explore three essential ways followed by some command options you can use through the process.

Before we understand how to exit Vim, make sure you satisfy all the prerequisites.

  1. Obviously a Linux System
  2. Terminal Window / Command Line Access (Activities > Search > Terminal)
  3. Sudo or Root permissions in User Account.

How to Exit Vim from Terminal

To make sure the commands execute properly in Vim, switch to Command Mode.

  1. Click the Esc Key.
  2. Make sure the --INSERT-- label vanish from the lower-left corner of your screen.
  3. Type :w , and hit Enter to save changes before exiting. Executing this command, Vim will save & respond by detailing how many characters written on the hard drive by outputing the file name.
This is a test document.

"test.txt" [New]  3L 70C written

4. To exit Vim, type :q and press Enter.

This is a test document


You can also use some methods as shortcuts by pressing the [Esc] key & typing out Shift + Z Z to save & exit.


By typing Shift + Z Q if you want to exit without saving the made changes in the file.

How to Exit Vim Using Shortcut Key

You can also exit Vim by using the below shortcut keys as a plus point in command prompt.

In addition to command mode, Vim also has the option for shortcut keys:

  • Press Esc > Shift + ZZ to save the current file & exit.
  • Press Esc > Shift + ZX to exit Vim without saving the current file.

List of More Commands to Exit Vim

Here are some more command options to exit Vim.

EscSwitch to command mode
:qExit Vim
:q!Exit Vim & Ignore the changes
:wWrite out the changes & alterations
:wqSave the changes & exit Vim
: xSave the instant changes & exit Vim
Commands to exit Vim

In this article, we’ve learned how to exit Vim text editor on Linux by using some simple commands If you have any thoughts or ideas on how to exit Vim, please write to us below.

We will be happy to hear your thoughts

      Leave a reply

      Techs Tricks
      Reset Password
      Shopping cart