The vi command to find-and-replace is
:s/find/replace/option
where "find" is the pattern to find and "replace" is what replaces it.
The two possible options are g and c - g is "global" and c is "confirm".
So for example, the command
:s/xyz/abc/g
will replace all occurrences of the string xyz on the current line with the
string abc without asking.
To perform the same find-and-replace on lines 1 through 10, while also asking about each replacement
:1,10s/xyz/abc/gc
To find-and-replace the first occurrence of "For" with "for" on just the current line
:s/For/for/
To insert the contents of a file2 into the file you are currently editing in vi,
the command is
:r file2
To insert the contents of a file2 after line 10,
the command is
:10r file2
You can also insert the output of linux commands into the file you are editing.
To insert a directory listing after line 10, the command is
:10r !ls
To insert the current date and time at the top of the file
:0r !date
Edit the file and make the following two changes: 1) change every letter A to the letter a; 2) insert your username and today's date (using the :r ! command) onto the top of the file.
Print the file and submit it at the beginning of the next lab period.