Re: vi globally append question
On Thu, Jul 15, 2004 at 02:25:52PM -0400, Rick Pasotto wrote:
> On Thu, Jul 15, 2004 at 07:45:26PM +0200, Matthias Czapla wrote:
> > On Thu, Jul 15, 2004 at 11:05:32AM -0400, David Turetsky wrote:
> > > > i have a file like;
> > > >
> > > > #
> > > > one
> > > > 123
> > > >
> > > > and i would like to APPEND a # at the beginning of
> > > > each line which is not started with a # . how can i do
> > > > it with vi or ed, so far, i 've tried;
> > > >
> > > > :%s/^[a-z]:[0-9]/#/g
> > > >
> > > > but this would CHANGE the first character of each line
> > > > to a hash, pls help.
> >
> > :1,$s/^\([^#].*\)/#\1/
> >
> > should do it in vi.
>
> Nope. Doesn't meet the spec. He wanted *every* line that did not start
> with '#', which would include blank lines. Your solution omits blank
> lines. Of course he might have mis-stated the specs.
You're right. This should be better:
:1,$v/^#/s/^/#/
Regards
Matthias
Reply to: