[comp.editors] How to insert a space down a table, using vi?

mark-d@wagner.cbs.umn.edu (Mark Dalton) (05/29/91)

Hi! I was wondering how I can insert a space in the same position
in each line down a table, starting with the second line.  I have
to do several files of a 1000 lines a piece(there must be an easy 
way).  Any suggestions?

	Also I remeber hearing of a listing of macros and a archive
site for comp.editors, could you let me know where that is?

						Thanks

						Mark 

rouben@math9.math.umbc.edu (Rouben Rostamian) (05/29/91)

In article <4016@ux.acs.umn.edu> mark-d@wagner.cbs.umn.edu (Mark Dalton) writes:
>Hi! I was wondering how I can insert a space in the same position
>in each line down a table, starting with the second line.

To insert a space following the fourth character in every line starting on
line 2 using vi, do

:2,$s/..../& /

Recall that the special character "&" is replaced with the pattern
matched in the previous expression.

There may be numerous variations on this theme; but you've got the idea.

With large files you may prefer using sed rather that vi, as in:
tail +2 infile | sed 's/..../& /' >outfile

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu

dwolfe@oakhill.sps.mot.com (Dave Wolfe) (05/30/91)

In <1991May28.214142.8549@umbc3.umbc.edu> rouben@math9.math.umbc.edu (Rouben Rostamian) writes:

>With large files you may prefer using sed rather that vi, as in:
>tail +2 infile | sed 's/..../& /' >outfile

That would lose the first line of the file; probably not what was
intended.  How about:

    sed '2,$s/..../& /' >outfile

-- 
Dave Wolfe (dwolfe@oakhill.sps.mot.com)		| Motorola Incorporated
"[RISC is] like obscenity,			| MMTG (formerly MPG)
 we all know what RISC is when we see it,	| Austin, Texas  78735-8598
 but no one can define it."	Chris Torek	| m/d OE112  (512)891-3246