使用 VIM 清理 ^M 符号

文章目录

    在 Ubuntu VIm 中打开了一个 Windows 上编辑过的代码文件,里面代码完全没有换行,只有大片的 ^M 符号。乱得完全无法阅读。

    ^M 符号是什么

    Unix uses 0xA for a newline character. Windows uses a combination of two characters: 0xD 0xA. 0xD is the carriage return character. ^M happens to be the way vim displays 0xD (0x0D = 13, M is the 13th letter in the English alphabet).

    windows 上的换行符是 \r\n, 在 VIM 中展示为 ^M.

    VIM 清理 ^M 符号的方法

    :%s/\r/\r/g
    

    参考

    https://stackoverflow.com/questions/5843495/what-does-m-character-mean-in-vim

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式