How to replace crlf with lf in a single file

In Notepad++ on the bottom panel on to the Right, right click on the area Windows (CR LF) and select UNIX (LF) this should replace all CRLFs with LFs

enter image description here

Below is the setting in IntelliJ at the bottom right enter image description here

Below is setting for VsCode at the bottom right enter image description here


The git installation on windows usually includes the dos2unix tool.

dos2unix <file>

But in your case you should use .gitattributes to prevent the file from being converted on windows.

A .gitattributes file can look like this

*.vcproj    eol=crlf
*.sh        eol=lf

From the .gitattributes documentation

Set to string value "lf"

This setting forces Git to normalize line endings to LF on checkin and prevents conversion to CRLF when the file is checked out.

Just commit the .gitattributes file and your file will be checkout out on every system with LF line ending.

Tags:

Windows

Git