^M 字符在 Vim 中是什么意思? [英] What does ^M character mean in Vim?

查看:41
本文介绍了^M 字符在 Vim 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 vimrc 中不断出现 ^M 字符,它破坏了我的配置.

I keep getting ^M character in my vimrc and it breaks my configuration.

推荐答案

Unix 使用 0xA 作为换行符.Windows 使用两个字符的组合:0xD 0xA.0xD 是回车符.^M 恰好是vim显示0xD的方式(0x0D = 13,M是英文字母的第13个字母).

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

您可以通过运行以下命令删除所有 ^M 字符:

You can remove all the ^M characters by running the following:

:%s/^M//g

其中 ^M 是通过按住 Ctrl 并键入 v 后跟 m,然后释放来输入的Ctrl.这有时缩写为 ^V^M,但请注意,您必须按照上一句中的描述输入它,而不是按字面意思输入.

Where ^M is entered by holding down Ctrl and typing v followed by m, and then releasing Ctrl. This is sometimes abbreviated as ^V^M, but note that you must enter it as described in the previous sentence, rather than typing it out literally.

此表达式将用空字符串(即什么都没有)替换所有出现的 ^M.我用它来摆脱从 Windows 复制到 Unix(Solaris、Linux、OSX)的文件中的 ^M.

This expression will replace all occurrences of ^M with the empty string (i.e. nothing). I use this to get rid of ^M in files copied from Windows to Unix (Solaris, Linux, OSX).

这篇关于^M 字符在 Vim 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆