As you all know, the line endings in DOS/Windows file differ than those of Unix/Linux, so whenever I open a file that I have created using Windows, I see hundreds of ^M after each line. Many people suggested solving this problem using:
I tried this but it doesn't work, because as far as I noticed, it tells Vim how to "save" the file, rather than how to "read" the file. What I want is keep line-endings as they are, be they Linux, Windows, or MAC, read them correctly, and save the file using the same format aftr editing.
preguntado el 09 de enero de 11 a las 09:01
to your vimrc.
:e ++ff=dosin opened file if vim failed to detect correct line ending.
" put this in your ~/.vimrc, resource then and try :Dos2Unix " dos2unix ^M fun! Dos2unixFunction() let _s=@/ let l = line(".") let c = col(".") try set ff=unix w! "%s/\%x0d$//e catch /E32:/ echo "sorry, first save your file." endtry let @/=_s call cursor(l, c) endfun com! Dos2Unix keepjumps call Dos2unixFunction()