vi dummy.txt
Type the following exactly:
:%s/dummies/Smarties/g
Then hit ZZ to quit.
The : (colon) makes this a "colon" or "ex" command. Do not forget the colon. The s stands for substitute. The g at the end stands for global, meaning the action should be performed for all instances of a string found on any given line. The % sign means " Do this for all lines in this buffer." Thus, the command can be read from left to right as:
For all lines of text in this buffer, substitute the string "dummies" with the string "Smarties" for every occurrence of the string "dummies" found on any given line.
If you didn't know this answer, you should stop taking this quiz and return to Lesson Three.
Copyright © 2001 jerry_y_wang@yahoo.com. All rights reserved.