Replacing carriage return ^M with Enter

前端 未结 5 1453
一向
一向 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条回答
  •  猫巷女王i
    2021-01-31 08:59

    :%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, e.g., inserted with C-V C-M.

      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
    

提交回复
热议问题