What’s the difference between CR, LF, and CRLF line endings?

Line break types differ across operating systems: CR (Carriage Return) is used by old Macintosh systems, LF (Line Feed) by Unix/Linux, and CRLF (Carriage Return + Line Feed) by Windows.

These characters determine how a new line is represented in text files. Understanding the CR LF distinction helps when handling cross-platform files or resolving Git or formatting issues.

Can you show examples of these in action or how editors handle them?

Absolutely! This tripped me up when collaborating across Windows and Linux.

In Windows, a new line is marked by \r\n (CRLF), while on Linux or macOS, it’s just \n (LF).

Older Macs used just \r (CR), but that’s rare now.

Most code editors (like VS Code or Sublime) let you view and even convert between these formats.

I usually make sure .gitattributes is configured to normalize line endings to avoid weird Git diffs.