Vim在每一行结束时显示^M。

我如何用在Vim中打开的文件中的普通换行符替换它?


当前回答

或者不使用vim,只需使用此命令修复换行符

fromdos <filename.txt>

希望能有所帮助!

其他回答

这个函数保存跳转列表

fun! Dos2unixFunction()
let _s=@/
let l = line(".")
let c = col(".")
try
    set ff=unix
    w!
    "%s/\%x0d$//e
catch /E32:/
    echo "Sorry, the file is not saved."
endtry
let @/=_s
call cursor(l, c)
endfun
com! Dos2Unix keepjumps call Dos2unixFunction()

或者不使用vim,只需使用此命令修复换行符

fromdos <filename.txt>

希望能有所帮助!

:g/^M/s// /g

如果你用Shift+6 Caps+M输入^M,它不会接受。

你需要输入ctrl+v ctrl+m。

我用sed做了这个:

Sed -i -e 's/\r/\n/g'文件名

这是唯一对我有效的方法:

: ff + + =

可以在http://vim.wikia.com/wiki/File_format找到它