Why is \r a newline for Vim?

后端 未结 5 2021
执笔经年
执笔经年 2020-11-27 09:30

From question How to replace a character for a newline in Vim?. You have to use \\r when replacing text for a newline, like this

:%s/%/\\r/g
         


        
5条回答
  •  轮回少年
    2020-11-27 09:58

    From http://vim.wikia.com/wiki/Search_and_replace :

    When Searching

    ...

    \n is newline, \r is CR (carriage return = Ctrl-M = ^M)

    When Replacing

    ...

    \r is newline, \n is a null byte (0x00).

提交回复
热议问题