7.B: Other Editors | 7: Editing Files | 7.A.2: Making Changes |
As with most editors, vi does actually change your file when as you enter the modifications. Instead, you work with a copy of your original file, and the modified copy replaces the original when you save the file.
In vi there are a number of ways (subcommands) to save files:
:w fname
| Write present file to fname |
:w | Write present file to original file |
:wq | Write file to original and quit editor |
ZZ | Write file to original and quit editor |
Because changes are permanent until you save (write) your file, if you make a major mistake while editing your file, it may be easier to abandon your editing and start again with the original file:
:q! | Quit without writing file |
Especially at first, a good idea is to save a temporary version of the file (just in case you did something useful with your editing, but are not sure):
:wq temp | Write to temp and quit |
:wq vi.doc | Write to vi.doc and quit |
:wq
vi.doc
:learn vi
while in command mode.
Now let's look some more modern editors in the next section.
7.B: Other Editors | 7: Editing Files | 7.A.2: Making Changes |