How To Exit (Quit) Linux Vim/Vi Editor - PhoenixNAP
Có thể bạn quan tâm
Vim is a core text editor for any IT professional working with Linux, built on the original Vi program. It is pre-installed on every distribution and accessible over SSH, making it the tool developers and system administrators use for quick file edits and configuration changes.
While Vim offers immense power, learning the essential commands is a prerequisite for anyone who interacts with a Linux server.
This guide will show you a few different ways to exit the Vim text editor.

Prerequisites
- A Linux system (this tutorial uses Ubuntu 22.04).
- Command-line access.
- Vim installed.
Exit Vim Using Esc Key
Vim operates in different modes, each with a distinct purpose and set of commands. To exit Vim, the editor needs to be in Normal mode. To switch to Normal mode, press the Escape key. When switching from Insert mode, you should see the ––INSERT–– label disappear from the lower-left corner.
Exit Vim without Saving Changes
If you made no changes, take the following steps to exit Vim:
1. Press the Escape key.
2. Type :q.

3. Hit Enter.
The system exists Vim and brings you back to the command line.
Exit Vim and Save Changes
To save changes and exit the editor, take the following steps:
1. Press the Esc key.
2. Type :wq. Including w ensures Vim saves the file, while q exits the editor.

3. Hit Enter.
Note: If you want to personalize your Vim interface and add syntax highlighting, learn how to change and use Vim color schemes.
Exit Vim and Discard Changes
If you have made changes using Vim but want to discard them, take the following steps:
1. Press the Escape key.
2. Type :q!. The q stands for quit, and the ! forces Vim to discard any changes.

3. Hit Enter.
Conclusion
This article explained several ways to exit the Vim text editor, depending on whether you want to save or discard the changes.
Next, learn other essential Vim commands.
Was this article helpful?YesNoTừ khóa » Vi Commands Exit
-
More Linux Resources
-
How To Exit (quit) Linux Vi Editor With Or Without Saving Changes Step ...
-
How To Exit The Vi Or Vim Editor - How-To Geek
-
Quit The Vi Editor Without Saving Your Changes
-
How To: Vi / Vim Save And Quit The Editor Command - NixCraft
-
How To Exit Vim – Vim Save And Quit Command Tutorial
-
How Do I Exit Vim? - Stack Overflow
-
Saving Changes And Quitting Vi
-
How To Exit From Vi In Linux Code Example
-
How To Exit A File In Vi / Vim Editor In Linux - Tecmint
-
Basic Vi Commands - Colorado State University
-
How To Exit Vim? Multiple Ways To Quit Vim Editor - It's FOSS
-
How To Save A File In Vim / Vi And Quit The Editor - Linuxize
-
10 Ways To Quit/Exit From Vim Editor In Linux/UNIX? Examples - Java67