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

前端 未结 10 575
感动是毒
感动是毒 2021-01-31 03:01

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 c

10条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 03:26

    You don't need to use hexl-mode. Instead:

    • open file in a way that shows you those ^M's. See M-x find-file-literally /path/to/file above. In XEmacs you can also do C-u C-x C-f and select binary encoding.
    • select the string you want replace and copy it using M-w
    • do M-% (query replace) and paste what you want to copy using C-y
    • present Enter when prompted to what replace it with
    • possible press ! now to replace all occurrences

    The point is that even if you don't how to enter what you are trying to replace, you can always select/copy it.

提交回复
热议问题