Starting Your VI Session
From the command line of you Unix or DOS system:
To open the file myfile:
vi myfile
NOTE: IF myfile does not exist vi will create it.
In command mode:
To save a file, and exit:
ZZ
To save a file and keep working:
:w!
To exit a file WITHOUT saving it:
:q!
To reopen the current file and discard any changes not saved:
:e!
To open a myfile file without leaving you current file.
:e! myfile
NOTE: Don't forget to save the second file before you go back!
To go back to the first file (above).
:rew!
NOTE: Don't forget to save the second file before you go back!
To edit a list of files:
From the command line of your Unix or DOS system:
vi myfile yourfile herfile theirfile
In command mode:
To move to the next file in a list of files. (as above)
:n
If you have made changes to the first file you must save it (I do) before moving to the next
file, in the list of files to edit.
To save the current file
:ZZ Or :w!
To move back to the first file in a list of files:
:rew!