home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 33.4 Useful ex Commands Chapter 33
Batch Editing
Next: 33.6 Change Many Files by Editing Just One
 

33.5 Running Editing Scripts Within vi

Because vi is built on top of the ex line editor, you get all the power of a line editor as well. Any experienced vi user issues ex commands all the time - but usually one by one, at the colon prompt.

The one exception is the .exrc file (30.6 ) , which is, at bottom, a list of commands for ex to run on startup - in short, an editor script.

What many beginners don't know is that you can save a sequence of ex commands in any file, and execute it with the :so command (33.4 ) . For example, Bruce Barnett uses this trick to set himself up specially for editing FORTRAN programs (31.11 ) .

In general, sed (34.24 ) is better for general-purpose batch editing - such as making a set of global substitutions over and over again on multiple files - therefore, :so is most often used for reading in setup commands. Keep in mind though; any time you find yourself issuing the same commands over and over again, think script!

- TOR


Previous: 33.4 Useful ex Commands UNIX Power Tools Next: 33.6 Change Many Files by Editing Just One
33.4 Useful ex Commands Book Index 33.6 Change Many Files by Editing Just One

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System