In emacs, how to strip CR (^M) and leave LF (^J) characters?
No need to find replace. Just use.
M-x delete-trailing-whitespace
You can also set the file encoding through
C-x RET f unix
No need for hexl-mode for this. Just do a global-search-and-replace of ^J^M with ^J Works for me. :) Then save the file, kill the buffer, and revisit the file so the window shows the new file mode (Unix vs DOS).
Oops. That ^J^M needs to be entered as two literal characters.
Use c-q
c-j
, c-q
c-m
and for the replacement string, use c-q
c-j
.