By Emacs, how to join two lines into one?

Solution 1:

Place point anywhere on the last line of the group of lines that need joining and call

M-^

repeatedly until all the lines are merged.

Note: It leaves one space between all of the now joined lines.

Solution 2:

M-x join-line will join two lines. Just bind it to a convenient keystroke.

Solution 3:

Multiple Cursors combined with M-^ will collapse all selected lines into one with all extraneous white-space removed.

For example to select an entire buffer, invoke multiple cursors mode, collapse into one line, and then disable multiple cursors mode:

C-x h
M-x mc/edit-lines
M-^
C-g

Solution 4:

Just replace newlines with nothing.