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
  • 31,901
  • 69
  • 184
  • 271
  • 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
  • 8,275
  • 3
  • 25
  • 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
  • 167,457
  • 16
  • 250
  • 324
Bambu
  • 548
  • 6
  • 16
3

Time for global:

:59,$g/^/pu_

For more see:

:h :g
:h :pu
:h registers
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101