How to join every second line in Vim?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Thinking It Over
--
Chapters
00:00 How To Join Every Second Line In Vim?
00:54 Accepted Answer Score 41
01:28 Answer 2 Score 38
01:56 Answer 3 Score 26
02:11 Thank you
--
Full question
https://superuser.com/questions/168942/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#vim #normalmode
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Thinking It Over
--
Chapters
00:00 How To Join Every Second Line In Vim?
00:54 Accepted Answer Score 41
01:28 Answer 2 Score 38
01:56 Answer 3 Score 26
02:11 Thank you
--
Full question
https://superuser.com/questions/168942/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#vim #normalmode
#avk47
ACCEPTED ANSWER
Score 41
i would do this:
start recording a macro 'q':
qqJjq
replay the macro 'q' 500 times:
500@q
(actually it is not a macro called 'q', it is a named register called 'q'. instead of interactively fill that register as in 1., you could also do :let @q = "Jj"
and then do 2.)
ANSWER 2
Score 38
To do this on every line of the file:
:%normal J
or, shorter:
:%norm J
To do this on just a portion of the file, select the lines with V or get a range some other way:
:'<,'>global/^/normal J
or, shorter:
:'<,'>g/^/norm J
ANSWER 3
Score 26
What about this:
:g/$/j
or
:g/$/j!
and group every three lines
:g/$/j3