vi dummy.txt
Hit i to enter insert mode, then type the text:
Vi is for dummies.followed by the Enter key. Then hit Esc to enter command mode and type:
22.
The dot command repeats the last buffer change the number of times specified, in this case 22 times. You only needed to manually enter the sentence once on the first line. Don't forget to use ZZ to save and quit.
Note that the above answer does not work with Solaris vi (and probably most non-clone implementations), so the "ugly" answer is also acceptable. You will know what the "ugly" answer looks like when you see it, and it will still contain the same number of occurrences of the desired text.
Update 2007-11-18:
Bryan Deter pointed out that a more efficient solution would be:
23iVi is for dummies.followed by the Enter key and Esc. Note that this also suffers from the same problem with Solaris vi.
If you didn't know this answer, you should stop taking this quiz and return to Lesson Two.
Copyright © 2001 jerry_y_wang@yahoo.com. All rights reserved.