Replacing carriage return ^M with Enter

前端 未结 5 1443
一向
一向 2021-01-31 08:24

I know how to remove ^M in my files (%s/^M//g), but this one is just one line I\'d like to replace ^M with enter... what\'s the enter char

5条回答
  •  执笔经年
    2021-01-31 09:02

    To replace carriage return character (which is ) 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 , so your initial request is not valid.

提交回复
热议问题