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:
set fileformat=dos
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.
Any idea?
Add
to your vimrc.
Run
:e ++ff=dosin opened file if vim failed to detect correct line ending.