This article introduces how to change the default line ending format to LF in Atom, a text editor beloved by many programmers. On Windows, the OS default is CRLF, so you’ll want to change it.
Settings > installed packages > line-ending-selector > OS default => LF
Issues with CRLF as Default Line Ending
The default line ending format on Windows is CRLF. This treats two characters, CR (Carriage Return) and LF (Line Feed), as the line ending. On the other hand, Linux and Mac only treat LF as the line ending.
Due to this difference, when you open a file created on Windows in Linux or Mac, the line endings will be incorrect. Conversely, when you open a file created on Linux or Mac in Windows, the line endings will be incorrect.
Benefits of Setting Default Line Ending to LF
By setting the default line ending to LF, files created on Windows won’t have incorrect line endings when opened in Linux or Mac. Also, conversely, files created on Linux or Mac won’t have incorrect line endings when opened in Windows.
Summary
To solve the problem of incorrect line endings when opening files created on Windows in Linux or Mac, we changed Atom’s default line ending format to LF.
Changing the default line ending format can be easily done from Atom’s settings.
I hope this is helpful.