Solaris Advanced User's Guide

Saving Changes and Quitting vi

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

Saving

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


:w

Press Return.

Saving and Quitting

Save and quit by typing:


:wq

Press Return. Alternatively, type ZZ.

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

Quitting Without Saving

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


:q

Press Return. If you have made changes, vi does not let you quit with :q. Instead, it displays the following message.


No write since last change (:quit! overrides)

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


:q!

Press Return.