:q | This command quits the "vi" editor, using the "last line mode" of vi. If you've made any changes to the file, "vi" will not let you quit this way. |
:q! | This command quits the "vi" editor, and automatically discards any changes you've made to the file. |
:wq | Write the changes to the file, and then quit the editor. This saves your changes to the disk. |
ZZ | This is the same as ":wq". |
The following exercise shows you how to open a file and quit the file without saving your changes.