I just learned how to replace newlines with other characters in Emacs. I found Jeremy's blog post from 2007.
I type:
M-x replace-string <return>
C-q C-j
replacement_string_of_choice <return>
C-q
is emacs' quoted-insert
, which works for inserting control characters; C-j
is the function newline-and-indent
which inserts a newline and indents to your major mode.C-q
also works in Xcode as described in this Stack Overflow question