Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

Why a multi-line text file appears as single line in Notepad

πŸ“… 2012-Nov-05 ⬩ ✍️ Ashwin Nanjappa ⬩ πŸ“š Archive

A text file with multiple lines of text appears concatenated into a single line when opened in NotepadΒ on Windows.

This happens because of the difference in the way the end-of-line is written by Linux (or other Unix-based OS) and Windows. If this text file was created on Linux and opened on Windows using Notepad, this problem occurs.

Linux uses the newline character (ASCII: 0x0A) to indicate end-of-line. Windows uses two characters: carriage return (ASCII: 0x0D) followed by newline (ASCII: 0x0A) to indicate end-of-line.

Almost any Windows editor other than Notepad, like Notepad++ for example, can understand both types of end-of-line indicators and can open such text files correctly.