|
Several last-line mode commands are available for saving your
work and exiting vi. You should save your work to disk periodically
using the
:w
(write) command. This writes the file to disk and leaves you in vi. To
save a copy of the file currently being edited to disk under a new
name, use the
:w
command followed by a new file name.
This is a good way to make a backup of the file. To save the file and
quit, you can use either the
:wq
or
ZZ
commands. If you have accidentally
made changes and want to discard them without saving or you want to
exit vi and ensure that you have not made any changes, use the
:q!
(quit) command. If you open a
read-only file and wish to modify it, you can save changes and
overwrite the existing file with the
:wq!
(write-quit) command. The Figure shows the various save/exit options.
|
|