Running Editing Scripts Within vi (Unix Power Tools, 3rd Edition)
20.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
(Section 17.5), 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 (Section 20.4). For example, Bruce Barnett uses this trick
to set himself up specially for editing FORTRAN
programs (Section 18.10).
In general, sed
(Section 34.1) 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
20.4. Useful ex Commands20.6. Change Many Files by Editing Just One
Copyright © 2003 O'Reilly & Associates. All rights reserved.
Wyszukiwarka
Podobne podstrony:
ch20ch20 (8)ch20ch20ch20 (2)ch20 (3)ch20 (17)ch20 (16)CH20ch20ch20Ch20 pg645 654ch20ch20ch20więcej podobnych podstron