LF
LF (Line Feed) is a C0 control character that moves the cursor down one line. It is the standard line terminator on Unix systems and one of the most frequently encountered control characters.
Syntax
LF 0x0A
LF = 0x0a ;
Description
Per ECMA-48 §8.3.74, LF "causes the active presentation position to be moved to the corresponding character position of the following line in the presentation component."
In default operation, LF moves the cursor down one line while remaining in the same column. If the cursor is at the bottom of the scrolling region (set by DECSTBM), the display scrolls up.
LNM mode interaction
When the Line Feed/New Line Mode (LNM, DECSET mode 20) is set, LF additionally performs a carriage return, moving the cursor to column 1 of the next line. In the default (reset) state, LF only moves down.
VT/FF
The Vertical Tab (VT, 0x0B) and Form Feed (FF, 0x0C) characters are treated identically to LF by virtually all terminal emulators.
Unix line endings
Unix systems use LF alone as the line terminator. The terminal driver's output processing (specifically the onlcr flag) translates LF to CR+LF on output so that lines start at column 1. When the terminal is in raw mode, this translation is disabled and LF only moves the cursor down.
Examples
printf 'Line 1\nLine 2' # \n is LF — move to next line
Specifications
| Specification | Section |
|---|---|
| ECMA-48 | §8.3.74 |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Handler linefeed() at term/mod.rs:1423 |
| Bobcat | ✓ | 0.9.0 | Basic C0 control, handled in TerminalCtrl library |
| contour | ✓ | v0.1.0 | Implemented in executeControlCode; calls linefeed() |
| foot | ✓ | Yes | Implemented in vt.c:227-234, also handles VT and FF |
| Ghostty | ✓ | v1.0.0 | LF, VT, and FF all trigger linefeed in stream.zig:770 |
| iTerm2 | ✓ | Yes | |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | |
| mintty | ✓ | Yes | Handled in do_ctrl() at src/termout.c:1705-1708 |
| mlterm | ✓ | rel-0_2_1 | |
| PuTTY | ✓ | 0.45 | |
| Rio | ✓ | v0.0.28 | |
| rxvt-unicode | ✓ | rxvt-unicode-1.2 | |
| st | ✓ | 0.6 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | Handled in performer.rs:380 via ControlCode::LineFeed, also handles VerticalTab and FormFeed identically |
| Windows Terminal | ✓ | Yes | LF, FF, and VT are identical in function (OutputStateMachineEngine.cpp:68-72) |
| xterm | ✓ | Yes | Implemented in charproc.c:3732 as CASE_VMOT. Handles LF, VT, and FF |
| xterm.js | ✓ | 2.3.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | |
| GNU Screen | ✓ | v.4.2.0 | Implemented in Special() function at src/ansi.c:684-689 |
| tmux | ✓ | 0.8 | Also handles VT and FF; respects CRLF mode |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.5.0-beta | |
See also
- CR — Carriage Return — Return cursor to column 1
- NEL — Next Line — Equivalent to CR+LF as a single control
- IND — Index — Similar downward movement, unaffected by LNM
- LNM — Line Feed/New Line Mode — Mode that alters LF behavior