Saving files and quitting vi
When editing a file, you are actually making changes to a copy of
it that vi has created.
After you have made several changes to a file, you can write these
to the original file to update it. Before quitting vi,
you must write all the changes to the file to save your work.
To save a file and/or leave vi you must switch to
command mode, if you are not
already in it. You can always enter command mode by pressing <Esc>
until the terminal beeps or flashes at you.
There are several ways to save files and leave vi, each of
which begins with you typing a colon character (:):
Save the current file (write file) but do not exit. This command
fails if the file is read-only. You can save under a different
name by adding a filename: for example, :w newfile
saves the current file as newfile if that file does not
already exist. The command :w
writes to the file if it already exists but fails if it is read-only.
Use :w! to overwrite a read-only file. (The exclamation
mark tells vi to ignore any error conditions.)
Quit vi. This command fails if you have made changes to a file since
the last time you saved it. (If you really want to quit without saving,
type :q!. This causes vi to quit without saving
the current file.)
Save the current file and exit vi. The command
:x is equivalent to this, except that it only saves the
current file if you have changed it.
These commands fail if the current file is read-only, or you are
editing more than one file. See
``Editing more than one file''
for details. (For information on read-only files, see
``Access control for files and directories''.
Moving around a file
What to do if you get stuck
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005