Converts text files from M$ (CR/LF) to Linux (LF) , and vice-versa

Solution 1:
edit file with vim and do:
:set ff=unix

Solution 1 a:
edit file with vim and do:
:e ++ff=dos

The :e ++ff=dos command tells Vim to read the file again, forcing dos file format.
Vim will remove CRLF and LF-only line endings, leaving only the text of each line in the buffer.

then

:set ff=unix

set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.


Solution 2:
Well if you need convert some files that was develop with M$ and remove ^M in Linux. You may use tofodos and you may run this simple script to convert files from some directories:
find . -type f -exec dos2unix {} \;
find . -type f -exec sh -c 'file --mime-encoding "{}" | grep -qv "binary$"' \; -print | while read file; do sed -i -e '$a\' $file; done

But other problem, some M$ files don't have an eof (end of line) in last line of the file, just have an eof (end of file)
On vim we see [noeol] when edit the M$ file. This information have several years, I don't know if they have fixed it meantime.