[Novalug] vi question

Mark Smith mark at winksmith.com
Sun Apr 12 04:27:32 EDT 2009


On Sat, Apr 11, 2009 at 11:11:26PM -0400, Jon LaBadie wrote:
> On Sun, Apr 12, 2009 at 09:04:06AM +1200, Mark Smith wrote:
> > :v,^$,s,^,  ,
> > 
> > v - for each line that does NOT match the following pattern do the following command
> >     (see 'g' for the does match case)
> > 
> > s - substitute
> 
> Just for balance, the global cmd would be usable too:
> 
>   : g/./s/^/  /

true and good point, but not to be outdone, if you have a truly
large file, you can speed things up considerably by using the '-n'
flag to vim.  that will prevent a swap file from being used, but
if you're trying to edit a couple hundred thousand line file for
this one purpose, it won't matter and it'll be much quicker.

> > On Sat, Apr 11, 2009 at 04:37:07PM -0400, Charles M Howe wrote:
> > > List,
> > > 
> > > I have a fairly length text file that I created using vi. It consists of
> > > data, one line, then, usually but not always a blank line. I wish to add
> > > two spaces at the beginning of eac line, but I would prefer not to put
> > > them in the blank lines. How can I do this? Fwiw, I have a copy of
> > > "Linux in a Nutshell", 5th edition, which has a chapter on vi. (If you
> > > can tell me what page the info is on, that would be a bonus.)

-- 
Mark Smith
mark at winksmith.com
mark at tux.org



More information about the Novalug mailing list