A question on .exrc while using vi

James Cummings james at dlss2.UUCP
Thu Dec 6 05:54:20 AEST 1990


In article <q5LoT4w163w at mudos.ann-arbor.mi.us> mju at mudos.ann-arbor.mi.us (Marc Unangst) writes:
>joshi at motcid.UUCP (Abhay B. Joshi) writes:
>> I have a simple text-file containing the following text (3 lines): 
>> 
>> 	The goal:
>> 	All I am trying to do is replace the 'the's by 'an's.
>> 	That's all.
>
>Son, vi is the wrong tool for the job.
>
>ed file <<Frobozz
>1,$g/the/s//an/g
>w
>q
>Frobozz
>
	Well, I wouldn't say vi is the "wrong tool for the job"!  Simply
do the following:

	:%s/the/an/g

	This is the equivalent of the above ed command...which boils down
to a matter of personal taste.
	The only problem I see with either of these solutions, is that the 
word "theatre" becomes the word "anatre"....boo-hisss!  A more practical 
solution would be in three steps, like so:

	:%s/ the / an /g
	:%s/^the /an /g
	:%s/ the$/ an/g

	There is probably a fancier way to do all of this in one swift move
but it escapes me for now.  Do note the use of spaces and the fact that we
are also looking for the 'the's that are at the begining and ending of lines
while preserving the integerity of words like "either", "theatre", etc.



More information about the Comp.unix.questions mailing list