Replacing carriage return ^M with Enter
我知道如何删除我的文件中的^M ( %s/^M//g ),但这只是我想用输入替换^M一行...... VIM中的输入字符是什么(要使用在通信线路模式下)。
You can replace one character using r<CR> in normal mode.
Or you can enter a "return" in command line mode by typing <Cv><CR> .
To replace carriage return character (which is <Cm> ) with line feed character (which is unix line break character) you should run a bit strange command:
%s/r/r/g
It looks like if it is doing nothing, but in regular expressions and double-quoted strings carriage returns are represented using r and line feeds with n , while in the replacement part of :s command and substitute() function they mean the opposite.
Note that in terminal Enter produces <Cm> , so your initial request is not valid.
:%s/r//g only works when:
set ff=unix , which when done, automatically converts all CRLF to LF
set ff=dos and CR is a rogue char that is not preceded by LF, eg, inserted with CV CM .
CR in LF CR pairs will not be found.
Therefore, if all you want is to convert every LF CR to LF , you should use:
:set ff=unix
:w
链接地址: http://www.djcxy.com/p/49326.html
下一篇: 用回车替换回车^ M
