To my django web project, I'm adding HTML files from a template. In Vim, these HTML files don't show anything wrong, i.e. no CR characters are visible. But when I do a git diff, they show up. Since they're not visible in Vim, I'm not able to do :%s/^M//g
or :%s/\r//g
, as both of them show pattern not found
error. BUT they're still visible in git diff. I don't want them to be seen in git. git config --global core.autocrlf true
doesn't help either
I got the answer after little bit of googling after seeing @torek's answer.
I just had to do :set fileformat=unix
in Vim!
set ffs=unix " disable "file format = dos" detection
in my.vimrc
to defeat this by default. (But that may not be what you want, I'm just showing how to disable auto-dos-mode here.) – torek Mar 28 '15 at 18:48:set fileformat=unix
solves the problem, all thanks to your pointers and a little bit of googling :) – Rushi Agrawal Mar 28 '15 at 18:55