If I have to replace newlines with comma for all lines between Pattern 1 and Pattern 2, how do I do it?
From:
Pattern 1
abcd
edfgads asd
adsad
...
Pattern 2
to:
Pattern 1, abcd, edfgads asd, adsad, ..., Pattern 2
On
Use Pattern 1 and Pattern 2 as addresses, see :help cmdline-ranges:
:/^Pattern 1/,/^Pattern 2/-1 s/\n/, /
On
:g/Pattern1/norm V/Pattern2^MgJ
:g/ on lines matching Pattern1, run the normal mode keystrokes:
visual select as far as... /search for Pattern2gJ Join selected lines, without adding spacesNB. Type the ^M with Ctrl-V <Enter>, or Ctrl-Q <Enter>
On
For vim it would be
:%s/\n/, /g
You search for a newline character: \n and replace it with comma and space: , which is done globally g, these options are split by / character.
More info about replace in vim you can find here
How about
Search
The replace part should be clear without an explanation.