Vim在每一行结束时显示^M。
我如何用在Vim中打开的文件中的普通换行符替换它?
Vim在每一行结束时显示^M。
我如何用在Vim中打开的文件中的普通换行符替换它?
当前回答
比如: : % s / \ r / / g 这招对我很管用。
它的作用是清除所有行的末尾,去掉^M,就是这样。
其他回答
sed s/^M//g file1.txt > file2.txt
其中^M是通过同时按下3个键,ctrl + v + M
在windows下,尝试:%s/<C-Q><C-M>/g
不需要使用Ctrl: : % s / r \ / /美元
这个函数保存跳转列表
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()
我用sed做了这个:
Sed -i -e 's/\r/\n/g'文件名