OpenWindows Advanced User's Guide

6.3.1 Saving Changes and Quitting vi

vi is rich in more or less synonymous commands that control saving the buffer contents to a file and quitting vi. These commands give you the option of saving, saving-and-quitting, or quitting-without-saving.

6.3.1.1 Saving

Save the contents of the buffer (write the buffer to the file on disk) by typing:

:w

followed by Return.

6.3.1.2 Saving and Quitting

Save and quit by typing:

:wq

followed by Return. Alternatively, type ZZ.

Note that the command ZZ is neither preceded by a colon nor followed by Return.

6.3.1.3 Quitting Without Saving

When you've made no changes to a file and simply want to quit, type:

:q

followed by Return. If you have made changes, vi will not let you quit with :q. Instead, it will display the message, No write since last change (:quit! overrides).

If you do not want to save your changes, type:

:q!

followed by Return.