3

I want to add a line break in vim from line 59 to the end of file.

- 0021: Paralleism
- 0022: Mazimum Sum Sequence
- 0023: Circles Intersection
- 0024: Physical Experiments

to this

- 0021: Paralleism

- 0022: Mazimum Sum Sequence

- 0023: Circles Intersection

- 0024: Physical Experiments

I tried the following but it doesn't work.

:59,Gs/$/$\n/

How can I achieve this with vim substitute?

shin
  • 28,830
  • 62
  • 170
  • 248
  • 1
    I reopened this question because it isn't an exact duplicate of the other. This question also deals with ranges, not just replacing newlines. – Randy Morris May 12 '14 at 23:29

3 Answers3

8

You should be able to accomplish it with this:

:59,$s/$/\r/
Ryan J
  • 7,910
  • 3
  • 22
  • 28
4

Another way to do this would be:

:59,$g/./norm o

Alternatively if you wanted to do this to all lines beginning with a - you could do:

:g/- /norm o
Ingo Karkat
  • 154,018
  • 15
  • 205
  • 275
Bambu
  • 538
  • 5
  • 16
3

Time for global:

:59,$g/^/pu_

For more see:

:h :g
:h :pu
:h registers
Peter Rincker
  • 39,385
  • 8
  • 64
  • 92