^[control-codes live in libghostty-vt

C0 control characters

LF Line Feed

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
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.

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.