Vi -- How to Insert a Blank Line to all existing lines

Vi -- How to Insert a Blank Line to all existing lines

Post by Erwin Susant » Wed, 28 Feb 2001 14:03:44



I forgot how to insert a blank line to all lines in my file
I just remembered:

:1,$s......

My current files have 40000 lines

Thank you for the help

--
Erwin Susanto
Circle Global Networks
9 Raffles Place, #09-03
Republic Plaza
Singapore
Phone: 227-9689
Fax: 227-5302

 
 
 

Vi -- How to Insert a Blank Line to all existing lines

Post by Kevin Mile » Wed, 28 Feb 2001 18:48:39



> I forgot how to insert a blank line to all lines in my file
> I just remembered:

> :1,$s......

> My current files have 40000 lines

> Thank you for the help

try this

:1,$s/$/^V^M/g

to get ^V^M  hold control-v and then control-m

Cheers

Kev

 
 
 

1. vi: convert double blank lines to single blank lines???

howabou
sed "/./,/^$/!d" file

or, more generally
sed "/./,/^ *$/!d" file

( copyright Brian Hiles, or is it Greg Uben ? )

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
                         JOIN SEDERS MAILING LIST
                            DISCUSS SED WITH US
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^

: >
: > I receive some files which contain, among other amusements, 2 (or more)
: > consecutive blank lines. I wish to compress every occurrence of multiple
: > blank lines to one blank line. I have already suppressed leading (and,
: > for that matter, trailing) white space, so all the lines actually match
: > /^$/ if that helps.
: >
: > Personally, I think it is not possible, but there are many of you out
: > there with even more perverse minds than mine. Thanks for looking at my
: > problem. Responses either here to the newsgroup, or, if you think this
: > too esoteric for general interest, to my E-mail address below.

: Not sure if this is supposed be done in vi. I think it should, and Sven
: has shown how to do this. Otherwise, you could use:

:   :%!cat -r

: Purely for esoteric interest :-> I include this sed script:

:   #!/usr/bin/sed -f
:   # on empty lines, join with next
:   :x
:   /^\n*$/{
:   N
:   bx
:   }
:   # now, squeeze all newlines
:   s/^\(\n\)*/\1/

: Casper Boden-Cummins.
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator                                      sed u soon
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

2. Installing 2 NE2000 compatible network cards

3. OT: oh...oh...Microsoft's growth SLOWS (.NET as salvation?)

4. inserting a blank line after every line - using sed

5. Realtime threads...

6. insert a blank line to divide blocks of lines

7. How do you connect to the internet with REDHAT 5.2

8. Vi command to insert at the begin of a line for lines in a file

9. multiple blank lines -> one blank line

10. inserting blank lines

11. Insert a line of text every nth line

12. How do I insert line numbers before each line using ed?