DEV Community

Serhat Teker
Serhat Teker

Posted on • Originally published at tech.serhatteker.com on

How to Exit Vim

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

"type :quit<Enter> to quit VIM"
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)