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

前端 未结 10 1461
小蘑菇
小蘑菇 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:12

    I usually use the following to cleanup my line endings:

    :g/^M$/s///
    

    To get the ctrl-M I usually type ctrl-Q, then ctrl-M and it puts it in. (In some environments it may be ctrl-V then ctrl-M.) I don't know why, but I find that one easier to remember than rq's.

    Don't forget to do :set ff=dos as well, or you'll end up saving with UNIX line endings still.

提交回复
热议问题