I have a huge file that I would like to format using Vim. For that, I would like to delete the newline characters at the end of every line.
For example,
I
want
this
to be
just one
line
should become
I want this to be just one line
I was thinking of doing it via the following command:
:%g/^/norm!‹a keyword that deletes the \n›
but I just don’t know which keyword might work for that, to automate the pressing the Del key on every on every line.
Thanks in advance!
The most idiomatic way of joining all lines in a buffer is to use
the
:joincommand:(Remove the
!sign if you want Vim to insert space between joinedlines. From the wording of the question I assume that you do not want
to add spaces.)
The same could be done interactively, if you prefer:
(Again, use
Jinstead ofgJif you want to separate joined lineswith spaces.)
Another option is the
:substitutecommand: