简体   繁体   English

Emacs ^ m行尾编码

[英]Emacs ^m end of line encoding

I was wodnering why my emacs started putting ^m at the end of every line, i know how to "fix it" but i was wondering what caused it to happen. 我在想为什么我的emacs开始在每行的末尾添加^ m,我知道如何“修复”它,但是我想知道是什么原因导致了它的发生。 I have been using emacs in windows for some time now and it started more recently. 我已经在Windows中使用emacs一段时间了,它是最近才开始使用的。 Does anyone know why this starts? 有人知道为什么会这样吗?

Most likely the reason is that the buffer is using '...-unix' coding system when the file contains Windows carriage-return/linefeed line ends. 最有可能的原因是,当文件包含Windows回车/换行符结尾时,缓冲区正在使用'...- unix'编码系统。 The mode line will show you the coding system in use. 模式行将显示正在使用的编码系统。 See 'Coding Systems' in the Emacs Manual. 请参阅Emacs手册中的“编码系统”

Ctrl-h C

will display the coding system currently in use. 将显示当前使用的编码系统。

I see this happening when the file contains both \\r\\n and \\n\\r line endings. 当文件同时包含\\r\\n\\n\\r行尾时,我看到了这种情况。 That is, someone has written broken Windows line endings to the file ( \\n\\r ). 也就是说,有人将损坏的Windows行结尾写入文件( \\n\\r )。

Go through your file and look for lines that start with ^M . 浏览文件并查找以^M 开头的行。 This implies that the carriage return was after the newline character on the previous line, which is incorrect. 这意味着回车在前一行的换行符之后,这是不正确的。

If that is the case, go back to the program that generated the file and make sure that it's writing correct Windows line endings. 如果是这种情况,请返回生成该文件的程序,并确保其写入的Windows行尾正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM