Search code examples
emacshexcarriage-returnline-endingshex-editors

How to strip CR (^M) and leave LF (^J) characters?


I am trying to use Hexl mode to manually remove some special characters from a text file and don't see how to delete anything in Hexl mode.

What I really want is to remove carriage return and keep linefeed characters.
Is Hexl mode the right way to do this?


Solution

  • 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).