In emacs, how to strip CR (^M) and leave LF (^J) c

2019-03-09 05:26发布

I am trying to use hexl mode to manually remove some special chars 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?

9条回答
孤傲高冷的网名
2楼-- · 2019-03-09 05:57

(in hexl mode) I'm not sure that you can delete characters. I've always converted them to spaces or some other character, switched to the regular text editor, and deleted them there.

查看更多
何必那么认真
3楼-- · 2019-03-09 05:59

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
查看更多
狗以群分
4楼-- · 2019-03-09 06:00

There's also a command-line tool called unix2dos/dos2unix that exists specifically to convert line endings.

查看更多
登录 后发表回答