gVim showing carriage return (^M) even when file mode is explicitly DOS

前端 未结 10 1479
小蘑菇
小蘑菇 2020-12-22 15:25

I\'m using gVim on Windows. My code shows ^M characters at the end of lines. I used :set ff=dos to no avail. The ^M characters remain

10条回答
  •  一个人的身影
    2020-12-22 16:15

    This happens when you have a mixture of Windows line endings and Unix ones. If you have 100 lines, 99 are \r\n and one is \n, you'll see 99 ^M characters. The fix is to find that one line and replace it. Or run dos2unix on the file. You can replace the Windows line endings with:

    :%s/\r\(\n\)/\1/g

提交回复
热议问题