Saving Changes And Quitting Vi

Oracle HomeagetestDocumentation Home > Solaris Advanced User's Guide > Chapter 6 Using the vi Editor > Ending a Session > Saving Changes and Quitting viSolaris Advanced User's Guide
  • Previous: Two Modes of vi
  • Next: Printing a File

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.

  • Previous: Two Modes of vi
  • Next: Printing a File

Từ khóa » Vi In Linux Save