Home

lineending

Line ending, also called end-of-line (EOL) or newline, refers to a character or sequence signaling the end of a line of text. It marks where one line ends and the next begins in files and data streams. The exact characters vary by system: Unix-like systems use a single line feed character LF (U+000A). Windows uses a carriage return followed by a line feed CRLF (U+000D U+000A). Classic Mac OS used a single carriage return CR (U+000D) for line termination in older days.

The concept originates from typewriter and teleprinter controls, where CR returned the print head and LF moved

When files are transferred between systems, line endings may be converted depending on the transfer mode (text

Handling: editors may detect and preserve or convert endings, display them, or normalize on save. The choice

to
the
next
line;
combining
both
allowed
separate
horizontal
and
vertical
movements.
In
practice,
line
endings
affect
editors,
compilers,
diff
tools,
and
version
control.
Mixed
line
endings
in
a
file
can
cause
issues
in
diffs
or
builds.
Common
remedies
include
normalizing
to
a
single
convention,
using
tools
like
dos2unix,
unix2dos,
or
editor
settings
that
convert
on
save.
Version
control
systems
offer
automatic
normalization,
for
example
Git’s
core.autocrlf
feature,
to
translate
endings
on
checkout
or
commit.
versus
binary).
Some
languages
and
protocols
treat
newline
as
a
control
character
within
strings,
with
environments
choosing
representations
such
as
\n
(LF)
or
\r\n
(CRLF)
in
source
code
or
data.
of
line
ending
affects
cross-platform
collaboration,
patch
formats,
and
build
scripts,
and
is
typically
governed
by
project
conventions.