Similar/Related to, but not covered by:
- Regular Expression to match cross platform newline characters
- Match (and delete) LF character in Notepad++ regex
I mostly work in .NET stack, where we want (almost) all our files to be CRLF.
In my opinion, git should never be editing the contents of a file, so my and my projects' and my colleagues' git settings are autocrlf=false
(i.e as-is, as-is
), feel free to have that debate on some other question :)
Occasionally someone will have bad git settings, or in some other way accidentally introduce LFs into some files in the git repo, and I want to grep the whole repository for files with LF line-endings, and then fix them to be CRLFs, on a file-by-file basis (in case there are, e.g. bash files which should regrettably be LF).
Every time I need to do this, I can't find the relevant Regex and have to work it out from scratch again.
So this question exists to document the correct regex.