[Novalug] vi question

Geoff McNamara geoffm at companionway.net
Tue Dec 4 14:10:47 EST 2007


Make sure you are in command mode with:
<esc><esc>

Then enter the command to change/substitute a character throughout the
whole file (every line) - globally (every occurrence within a line):
:%s/x/y/g

What that command means is:
: <-- starting a command
% <-- address range is the entire file
s <-- substitute
/x/y/ <-- (the delimiter here is "/" but any delimiter could be used)
      given the substitute command above change "x" for "y"
g <-- the global option which switches the command to substitute every
occurrence within a line (not just the first occurrence)

Enjoy,
-geoff

> List,
>
> How do I change all instances up to the end of a file of a single letter
> with another letter?
>
> I know. It ought to be simple. But I have pored through the chapter on
> vi in "Linux in a Nutshell" and I don't see it.
>
> Charlie
>
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org
> http://calypso.tux.org/cgi-bin/mailman/listinfo/novalug
>




More information about the Novalug mailing list