Why do line breaks look different in text files from different systems?
Quick answer
LF is a line-feed character alone; CRLF is a carriage return followed by a line feed. An editor may display either sequence as the same visible new line, so the layout alone does not reveal which is stored. Check an editor’s line-ending indicator or inspect the characters at line boundaries. If you only want to compare a file, avoid saving changes or confirming a conversion prompt.
The question, the details, the next step.
A practical checklist
Check whether the editor reports LF or CRLF.
Inspect characters at line boundaries if the distinction matters.
Check several boundaries to look for inconsistent endings.
Compare applications without saving changes.
Do not confirm a conversion prompt if you only want to inspect.
A few more useful answers
Does seeing each line on a separate row tell me whether the file uses LF or CRLF?
No. An editor may display different line-ending sequences as the same layout. Use an indicator or inspect the characters.
Can a file contain more than one kind of line ending?
Visual Studio documents encountering multiple line-break characters and may prompt about normalizing inconsistent ones. Check more than one boundary if consistency matters. [S1]
Will every program read LF and CRLF as equivalent?
That is not established here. .NET’s File.ReadLines recognizes both as line boundaries, but this does not guarantee that other applications handle them identically. [S2]
Sources
References used for this guide.
- [S1] Encodings and line endings in Visual Studio learn.microsoft.com · Checked
- [S2] File.ReadLines method (System.IO) learn.microsoft.com · Checked
