What does ^M character mean in Vim?

我一直在我的vimrc中获得^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).

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

:%s/^M//g

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.

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


:%s/r//g 

worked for me today. But my situation may have been slightly different.


翻译新的一行而不是删除它:

:%s/r/r/g
链接地址: http://www.djcxy.com/p/49466.html

上一篇: VIM ctrlp.vim插件:如何重新扫描文件?

下一篇: ^ M字符在Vim中意味着什么?