Vi on Linux: show ^M line endings for DOS-format files

Solution 1:

Try :set ffs=unix when starting vi (or set as default in vimrc) which should display all CR characters as ^M.

vi auto-guesses which format to use based on whether or not it encounters lines ending in just LF or both CR/LF.

Solution 2:

To show dos line endings for the current file:

:e +ff=unix

This forces the fileformat to unix, which will render CR as ^M


To make this setting permanent, add to ~/.vimrc:

set ffs=unix

Note that the .vimrc setting is ffs, not ff.