IT lexicon › Programming › Newline

Newline

Programming På svenska → Updated: 2026-10-02

The character that ends a line of text — \n, ASCII 10, historically called line feed.

The name comes from the teleprinter: LF advanced the paper one line, CR returned the carriage to the left margin. Unix decided in 1970 that a single LF was enough and let the driver handle the rest, while DOS and later Windows kept both characters — hence CRLF, and every file that appears as one endless line in the wrong editor. Classic Mac OS used a bare CR until Mac OS X switched to the Unix convention.

POSIX defines a line as zero or more characters followed by an LF, which is why tools like wc -l and diff complain about files missing a trailing newline. It is also why well-kept repositories end every text file with \n: without it the last line goes invisible in diffs and gets rewritten every time someone appends below it.

← Back to the lexicon