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
Asked
Active
Viewed 1,290 times
1

Rushi Agrawal
- 3,208
- 2
- 21
- 26
-
1vim will auto-detect "dos format" and you won't *see* the carriage-returns, but it will auto-restore them on write. I have `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
-
Thanks @torek, I think I got the answer. `: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
-
Does this answer your question? [Convert ^M (Windows) line breaks to normal line breaks](https://stackoverflow.com/questions/811193/convert-m-windows-line-breaks-to-normal-line-breaks) – Henke Oct 16 '22 at 15:39
1 Answers
0
I got the answer after little bit of googling after seeing @torek's answer.
I just had to do :set fileformat=unix
in Vim!

Rushi Agrawal
- 3,208
- 2
- 21
- 26