I have a file with these lines:
aa
bb
cc
dd
I want to convert this into:
aa
aa
bb
bb
cc
cc
dd
dd
Is this possible in VI?
Try this simple one:
:g/^/norm yyp
Yet another one(shorter):
:%s/.*/&\r&
Another one:
:%!sed p
I like g/^/t.
The g
(for global
) command will look for any lines that match a pattern.
The pattern we specified is ^
, which will match all lines.
t
will copy and paste, and finally
the dot
tells it to paste below.
Do I win for brevity?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With