How to exit vim?

If you are in the insert mode → press ESC to access command mode and then just type :q! + Enter

Ho to exit vim and safe?

Make sure that you are not in insert mode. If you are, press ESC to enter command mode. Then you can run :wq and voila, vim will safe your changes and exit to your terminal.

More useful vim commands

Now that you know how to exit vim, here are some more commands for you.

  • :x can also be used for exiting vim with saving your changes
  • :ex works just as :x
  • :wqa will save your changes in all tabs (in case you have more than one) and exit vim

Maker — Coder — Writer | Let me inspire you

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store