Reputation: 5559
I want to convert the vertical text in my file to horizontal. like
1
2
3
to
1 2 3
I can do this using the tr command tr '\n' ' ' <file
but I want to do this using vim
Upvotes: 0
Views: 3291
Reputation: 1547
Another way:
By replacing \n
with
:{fromLine},{toLine}s/\n/ /g
Upvotes: 1
Reputation: 36282
An easy one. Use a range from first line until last one and join them with an space between them:
:0,$join
Upvotes: 3
Reputation: 24812
Select the lines and join them with J
.
From :h J
:
*J*
J Join [count] lines, with a minimum of two lines.
Remove the indent and insert up to two spaces (see
below).
*v_J*
{Visual}J Join the highlighted lines, with a minimum of two
lines. Remove the indent and insert up to two spaces
(see below). {not in Vi}
Upvotes: 3