vi - How to quit the vim editor

vi - How to quit the vim editor

editor, exit, quit, vi, vim

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

  1. Hit the ESC key, this will enter Command mode.
  2. 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.
  3. 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)
  4. To execute the command, press the Enter key

 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.


Back to The Programmer Blog