How to quit VIM (saving or ignoring the changes)?


There are multiple ways of exitting VIM, but it depends on whether you actually want to save your changes or not.

Quitting without saving any changes

Press Esc to make sure you’re back to the normal mode. Then type :qa!and press Enter. If you would like to know what does it mean: : starts the command, q means “quit”, a means “all” (all buffers/tabs/files), and finally, ! says “don’t care if there are any changes”. You can omit the exclamation mark, in this case if you have some unsaved changes, VIM will force you to save first.

Quitting and saving the changes

Again, make sure you are in the normal mode by pressing Esc. Then type :wqa. You already know what q and a means, w means “write” as in write to disk. So before exiting the VIM it will write all your changes to disk.

Where to go from there

  • Do you know how to copy and paste a line in Vim?
  • If you need to know more, there’s a pretty good help within Vim itself. Type :help quit┬áin normal mode to access the documentation.

Recent Posts