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
- 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
| Terminal | Version | Support | Notes |
|---|---|---|---|
| VT220 | manual, 2nd ed., 1984 | Yes | §4.2 Control Characters |
| VT510 | manual, 1st ed., 1993 | Yes | Table 4–1 |
| xterm | patch 412, xterm-411a | Yes | |
| libghostty-vt | 0f171f6 | Yes | |
| kitty | 0.49.1, run in a VM | Yes | passes the 4 cases that show it working |
| foot | 1.28.0, run in a VM | Partly | fails LF-4 of the 4 cases that show it working |
| pyte | 0.8.2, run as a library | Yes | passes the 4 cases that show it working |
| xterm.js headless | 6.0.0, run as a library | Yes | passes the 4 cases that show it working |
| alacritty_terminal | 0.26.0, run as a library | Partly | fails LF-4 of the 4 cases that show it working |
| rxvt-unicode | 9.31, run in a VM | Partly | fails LF-4 of the 4 cases that show it working |
| VTE | 0.84.1, run as a library | Partly | fails 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