When comparing two files with same content but with line endings, vim diff does not detect the difference. Is there a way to make vimdiff show the difference.
When file(s) have inconsistent (dos vs. unix) line endings, Vim will detect them as unix, and lines will show trailing CR (^M
), also in a diff.
What you describe (no changes detected) happens when one file consistently uses dos, and the other consistently uses unix line endings. Vim then "abstracts away" the consistent line endings in the :help 'fileformat'
option value.
Some users put the 'fileformat'
value into the 'statusline'
, and use that to notice the discrepancy. (I do this with a conditional to only show it if it differs from the platform's default.)
If you want to show line ending differences inside the diff itself, you can force the 'fileformat'
to unix, either when starting:
$ vimdiff --cmd 'set fileformats=unix' file1 file2
or inside Vim:
:windo e! ++ff=unix