4.4.1.7. Saving and exiting
There are a number of commands available for saving the document and exiting vi , as shown in Table 4-10 ; you must press Enter after these commands.
Table 4-10. Saving text and exiting vi
Command | Description |
---|---|
:w | Write (save) using the current filename. |
:w newfilename | Write to the file newfilename (subsequent :w commands will still write to the original filename). |
:w! | Force-write (write even if in read-only mode). |
:q | Quit (succeeds only if the document is saved). |
:q! | Force quit even if the document isn't saved (abort!). |
:wq or :x or ZZ | Write and quit (exit with save). |