I have a text which is made of lines and some of them look like that:
A test1
test test
test testA test2
test test
test test
The line starts with A
(arbitrary but unique string) and ends with an empty line.
I like to remove all redundant newline symbols from the real lines (without affecting other lines, not matching the /^A/
) and make the lines look like that:
A test1 test test test test
A test2 test test test test
Once I'm at /^A/
, I can use the command :.,/^$/-2s/\n/ /
(range .,/^$/-2
applied to :s///
). Going over the whole file and doing it manually is rather mundane thus I have attempted to combine that with :g/^A/
:
:g/^A/.,/^$/-2s/\n/ /
But that produced error since in command after :g//
, the range wasn't recognized. I have tried to use normal
too - :g/^A/normal .,/^$/-2s/\n/ /
and :g/^A/exe 'normal .,/^$/-2s/\n/ /'
- with no luck.
Is there any way to run from under :g//
a command with range? Or is there any other easy (== without scripting) way to accomplish the same formatting task?