On Thu, 9 Mar 2000, Ben Donohue wrote:

> 
> hi slugs,
> just a quick question,
> using vi how do i insert a # in the first column of a long file. such
> that every line from top to bottom starts with a #

:1,$s/^/#/

Which means

    :           go into ex mode
    1,$         from line 1 to the last line in the file
    s           substitue the following pattern
    /^/         The pattern is the beginning of the line
    \#/         replace the first pattern with this one - a #

There are a number of other ways of doing it too, EG:

    :g/^/s//\#/

You might need to escape the # with a \ because # is special to vi (it
means the name of the previous file we were editting in this current
session. vim (the Linux version of vi) might be a little different.

Regards
Peter
----------
Peter Samuel                                [EMAIL PROTECTED]
Technical Consultant                        or at present:
eServ. Pty Ltd                              [EMAIL PROTECTED]
Phone: +61 2 9206 3410                      Fax: +61 2 9281 1301

"If you kill all your unhappy customers, you'll only have happy ones left"

--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to