^[control-codes
live in libghostty-vt

C0 control characters

LF Line Feed

View as Markdown

Move the cursor down one line, scrolling at the bottom margin.

LF
ECMA-48
§8.3.74 LF – Line Feed, p. 49
DEC STD 070
§5.4.4 Line Feed, p. 5-59
VT220
§4.2 Control Characters
VT510
4.2 Control Characters

Move the cursor down one line, keeping its column. If the cursor is on the bottom margin (the last line, unless a scrolling region has been set with DECSTBM), the lines of the scrolling region move up by one instead: the top line leaves the region, and a blank line appears at the bottom. Lines outside the region do not move.

A line feed does not return the cursor to the left margin. When a program prints \n, it is the terminal driver, not the terminal, that turns it into \r\n. Line feed/new line mode (CSI 20 h, LNM) makes the terminal do it instead, and is off by default.

Vertical tab (VT, 0B) and form feed (FF, 0C) do the same thing as a line feed.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.2 Control Characters
VT510manual, 1st ed., 1993YesTable 4–1
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMYespasses the 4 cases that show it working
foot1.28.0, run in a VMPartlyfails LF-4 of the 4 cases that show it working
pyte0.8.2, run as a libraryYespasses the 4 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 4 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails LF-4 of the 4 cases that show it working
rxvt-unicode9.31, run in a VMPartlyfails LF-4 of the 4 cases that show it working
VTE0.84.1, run as a libraryPartlyfails LF-4 of the 4 cases that show it working

Validation

LF-1: Down, not back

AB
\n
C
|AB___|
|__C__|
|_____|
cursor 2,4

LF-2: Scrolls at the bottom

A\r\nB\r\nC
\n
D
|B____|
|C____|
|_D___|

LF-3: Scrolls only the scrolling region

1\r\n2\r\n3\r\n4
\e[2;3r   # region is lines 2 and 3; homes the cursor
\e[3;1H
\n
X
|1____|
|3____|
|X____|
|4____|

LF-4: With line feed/new line mode

\e[20h    # LNM
AB
\n
C
\e[20l
|AB___|
|C____|
cursor 2,2
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.