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.
- Obviously a Linux System
- Terminal Window / Command Line Access (Activities > Search > Terminal)
- 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.
- Click the
- Make sure the
--INSERT--label vanish from the lower-left corner of your screen.
: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 3,20
4. To exit Vim, type
:q and press Enter.
This is a test document :q
You can also use some methods as shortcuts by pressing the
[Esc] key & typing out
Shift + Z Z to save & exit.
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:
Esc > Shift + ZZto save the current file & exit.
Esc > Shift + ZXto exit Vim without saving the current file.
List of More Commands to Exit Vim
Here are some more command options to exit Vim.
|Esc||Switch to command mode|
|:q!||Exit Vim & Ignore the changes|
|:w||Write out the changes & alterations|
|:wq||Save the changes & exit Vim|
|: x||Save the instant changes & 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.