< Previous | Contents | Next >
Saving Our Work
Like everything else in vi, there are several different ways to save our edited files. We have already covered the ex command :w, but there are some others we may also find helpful.
In command mode, typing ZZ will save the current file and exit vi. Likewise, the ex command :wq will combine the :w and :q commands into one that will both save the
Saving Our Work
file and exit.
The :w command may also specify an optional filename. This acts like “Save As...” For example, if we were editing foo.txt and wanted to save an alternate version called foo1.txt, we would enter the following:
:w foo1.txt
:w foo1.txt
Note: While the command above saves the file under a new name, it does not change the name of the file you are editing. As you continue to edit, you will still be editing foo.txt, not foo1.txt.