Skip to navigationSkip to content

A million people have visited this web page explaining how to close Vim, a notoriously difficult text-editing program

  • Keith Collins
By Keith Collins

Tech Reporter

Published This article is more than 2 years old.

“How to exit the Vim editor?”

That was a question asked by Stack Overflow user jclancy on August 6, 2012. If you don’t know, Vim is a text editor in which programmers write and edit code, and this question is just what it looks like: jclancy opened Vim, and couldn’t figure out how to close it. The question has more than a thousand upvotes, seven detailed answers, and has now been visited more than a million times, according to a blog post on Stack Overflow.

The difficulty of using Vim has been a running joke among programmers for years. To understand why, if you’re using a Mac or Linux computer, open the Terminal application. At the command prompt, type vim test.txt. That will create a text file, test.txt, which will open in Vim. Now try to close it and get back to the command prompt. If you can’t figure it out, just know that thousands of expert programmers who came before you couldn’t figure it out either.

In fact, according to the blog post on Stack Overflow, about 80 people visit this question every hour during work days. So if you’re still stuck, don’t worry, we’ll explain what to do below.

The first thing many programmers may do to try to get out of Vim is press control-c, or type quit, or type exit, or maybe exit(). None of these will work. If you press enough buttons, you might see the message jclancy saw: “type :quit<Enter> to quit VIM.” If so, you’ll probably try to type :quit and press enter, because you’re a perfectly reasonable person. But that won’t work either. As dirvine says in their answer to jclancy’s question, you have to hit the escape key first.

“Hit the Esc key,” dirvine says. Once you hit escape, “vim goes into command mode.” From there, dirvine offers nine commands you can enter to actually get out of Vim:

  • :q to quit (short for :quit)
  • :q! to quit without saving (short for :quit!)
  • :wq to write and quit (think write and quit)
  • :wq! to write and quit even if file has only read permission (if file does not have write permission: force write)
  • :x to write and quit (similar to :wq, but won’t write if there are no changes)
  • :qa to quit all (short for :quitall)
  • When you press :, a : will appear at the bottom of the screen.
  • Or you can press Esc ZZ (Esc Shift+Z Shift+Z) to write/save if the file was changed, then quit.
  • Or if you don’t want to save changes you can use ZQ instead.

See? It’s that easy. You won’t want to save the text file you created earlier, so just press escape, then type :q, and it will all be over. Phew.

The reason Vim can be so difficult for newcomers to use is because it’s actually built for maximum productivity. Experienced Vim users tend not to use their mouse, because Vim provides a complex, robust keyboard shortcutting system that is almost a language in itself. And despite its high learning curve, Vim was the fourth most popular text editing tool among the 64,000 programmers who took Stack Overflow’s most recent developer survey.

The Vim editor is also free, and ships with most modern operating systems. So now that you’ve had a taste, if you want to explore the full horror and beauty that is the Vim editor, try this video game, VIM Adventures, which forces you to use Vim keyboard combinations to move around a world. If you don’t rage quit within five minutes, you may have just found your new favorite text editor.


📬 Kick off each morning with coffee and the Daily Brief (BYO coffee).

By providing your email, you agree to the Quartz Privacy Policy.