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, scrpits or system configuration files located in /etc/ or /usr/local/etc/ directories.
vim [options] filename
How to exit VIM text editor
The procedure is as follows to quit vim/vi text editor:
- First, you need to switch to command mode. This can be done by hitting the Esc key. Next, you can type the following commands:
- :q to quit.
- :q! to quit without saving data/file.
- :x save and quit.
- :qa to quit all open files.
- 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.
Let us see some examples and method to exit from vim session.
How to exit vim editor in terminal (method #1)
- Press the Esc key
- Type :
- Next, type q
- Hit the Enter key
vim: How do I quit from Vi (method #2)?
- You can press the Esc key.
- Type SHIFT Z Z to save and exit.
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)
How to learn vim
Use vimtutor command. It starts the Vim tutor. The Vimtutor is useful for new Linux or Unix sysadmin or developers who want to learn their first Vim commands. By default, vimtutor starts in English or the language of the current locale will be used:
To start in other languages add language parameter as follows:
$ vimtutor it ## Italian ##
$ vimtutor es ## Spanish ##
$ vimtutor fr ## French ##
To see all installed languages run the following ls command:
$ ls /usr/share/vim/vim*/tutor/tutor*
You learned how to exit vim text editor using various options. See vim docs here for more info.
|Category||List of Unix and Linux commands|
|Firewall||CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|