Vim Editor How to Exit
Learn how to exit a Vim Editor
Published
Hit the Esc key to enter “Normal mode”. Esc key finishes the current command and switches Vim to normal mode. After that you can type : to enter “Command-line mode”. A colon (:) will appear at the bottom of the screen and you can type in one of the following commands. To execute any command, press the Enter key.
- :q to quit (short for :quit)
- :q! to quit without saving (short for :quit!)
- :wq to 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 only write if there are changes)
- :exit to write and exit (same as :x)
- :qa to quit all (short for :quitall)
- :cq to quit without saving and make Vim return non-zero error (i.e. exit with error)
Vim has extensive help - that you can access with the :help command - where you can find answers to all your questions and a tutorial for beginners.