I have a file in VI Editor like this:
I1 a b c d e f
g h i j k l m
o p q r s t u v
w x y z
I2 a b c d
e f g h i j k l m
n o p q r s t
u v w x y z
I3 a b c d e
f g h i j k l m n
o p q r s t u v w x y z
I'm trying to merge the 3 line that are after the line starting with I(^I) like this:
I1 a b c d e f g h i j k l m n o p q r s t u v w x y z
I2 a b c d e f g h i j k l m n o p q r s t u v w x y z
I3 a b c d e f g h i j k l m n o p q r s t u v w x y z
I have googled to see if I can join the 3 lines after the line containing I1
(that is, the line beginning with I
[^I]
) in VI editor and found the Join command that joins the next line to the current line like :g/^I/norm Jx
. But I would like to use this command for joining the next 3 lines to the current line.
It would be highly appreciated if any one can suggest me a method to do this via VI Editor or any scripting language.