Quit Vim

Yes, we all have been there: You are stuck and cannot escape Vim. It says:

"type :quit<Enter> to quit VIM"

Here is the solution to escape from this dead-end hell:

  1. Press Esc key.
  2. Hit :
  3. Press wq (q short for quit, w for write/save)
  4. Hit Enter

If you dont want to save the changes you made in the file use q! instead of wq.

For more

‘quit’ Alternatives

  • :x to write and quit (similar to :wq, but only write if there are changes)
  • :exit to write and exit (same as :x)
  • :qa to quit all (short for :quitall)
  • :1,5wq will save only lines 1 to 5 and quit

Shortcut Alternatives

After pressing Esc:

  • ZZ will save and quit
  • ZQ will just quit

All done!


  • 2020-10-30 : Added post image