Quitting the vi editor can cause quite the headache for newcomers to this Unix editor. After you're more familiar with vi this will seem like a silly article, but until then here's a quick guide on quitting the vim editor!
Quitting vi editor
- Hit the ESC key, this will enter Command mode.
ESC
- Type a colon ( : ), this will enter Command line mode.
:
You should see a : appear at the bottom of the screen. This confirms that you are in Command line mode and not editing the file. - Enter one of the following commands to suit your needs:
:q (quit, short for :quit)
:q! (quit without saving, short for :quit!)
:wq (write and quit)
:wq! (write and quit even if file has only read permission)
:x (write and quit, only write if there are changes)
:exit (write and exit, same as :x)
:qa (quit all, short for :quitall)
- To execute the command, press the Enter key
Enter
Congratulations! You have successfully learned how to quit the vi editor. Now go grab a beer and relax. If you need more help from the editor itself you can always run the :help command when your are in Command line mode.
:help