I suspect you do not want to use vi for this purpose (and I'm not sure you can, even if you wanted to). Instead, consider using ed (precursor to vi, and still available from within vi). The ed command allows you to edit a file in place; you can use a "here document" within a shell script to perform the editing, which automates the process.
Hope this helps.
__________________ The slowest component still sits at the keyboard. |