Chat Zalo Chat Messenger Phone Number Đăng nhập
How To Exit Vim? Multiple Ways To Quit Vim Editor - It's FOSS

How To Exit Vim? Multiple Ways To Quit Vim Editor – It’s FOSS

“How to get out of Vim?” “How to leave Vim?” “How do you get out of editor Vi?” “How to save and exit Vim?”

Here are some of the most searched questions on Google about the Vim editor. Vim, one of the best terminal-based editors, is known for its powerful features. Its ardent users swear by it, but it leaves new users baffled because of its “unusual shortcuts.” This even leaves them wondering how to exit the Vim editor.

In this article, I will show you several ways to exit Vim. We’ll also look at some interesting fun facts about getting out of Vim.

How to leave Vim?

As you’ve already seen in Vim’s advanced tips, there are several ways to get out of Vim. Let me list them one by one, along with the procedure.

Step

1: Enter the command mode by pressing

the Esc key Press

the Esc key: This is very important, because you need to exit the edit mode first before typing the

output commands.

Step 2: Exit vim using

commands

You can then type one of the following commands to exit Vim in a different mode

:

  • :q (yes, the colon is included in the command) – This will exit the editor. It may ask you if you are trying to quit Vim and there are unsaved changes.
  • :q! – Exit Vim without saving the data file (all unsaved changes are discarded).
  • :wq – Save the file and exit Vim.

Step 3: Press

the

Enter key Once you have chosen the output command, press enter to finally exit Vim and close the editor (but not the

terminal).

Note that when you press “:” the editor will have the following keystrokes at the bottom left of the terminal.

Other ways to exit

Vim

Normally, you should remember the above three commands and you should be good at quitting Vim. But as I said before, there are more shortcuts to leaving Vim. These are as follows

: Esc + 😡 + Enter Esc +

  • :qa + Enter Esc +
  • Shift ZZ

  • Esc
  • + Shift ZQ Now

it’s really up to you to choose how you want to exit the Vim editor. If you ask me, the first method is the one you should choose.

Save (without exiting) with the :w command and then you can use :wq to save and exit (w to save and q to exit). It is easier to remember q to quit smoking.

Facts and fun about leaving

Vim

If you’re feeling a little depressed because you didn’t know how to leave Vim, don’t do it, because you’re not alone. According to Stack Overflow, more than a million developers worldwide searched for ways out of Vim.

In fact, leaving Vim has become a topic of conversation in popular culture. Take this tweet, for example. This is one of the most popular taunts

about the “complexity” of exiting Vim:

The generalized difficulty is somewhat surprising, because if you run Vim you will see the information on how to exit it on the welcome screen:

But then, the obvious things are not so obvious sometimes. It is curious that we are so used to the shortcuts Ctrl+S, Ctrl+X that it baffles us when we do not find the same “standard” shortcuts elsewhere. I mean, even the Ctrl + C keys to stop commands don’t work here.

Vim is an excellent editor. If you can master its features, there will be nothing like it. System administrators spend a lot of time on the command line. Mastering Vim can be really beneficial. At the very least, you should master the basic commands of vim.

I hope this tutorial helped you save and exit Vim. Share your views and thoughts about it.

Contact US