LNM
LNM (Mode 20) is an ANSI mode that controls whether line feed characters (LF, VT, FF) also perform a carriage return, moving the cursor to the first column.
Syntax
CSI 20 h Set — Enable newline mode (LF implies CR)
CSI 20 l Reset — Disable newline mode (LF only moves down)
set-LNM = 0x1b, "[", "2", "0", "h" ; reset-LNM = 0x1b, "[", "2", "0", "l" ;
Description
Per ECMA-48 §7.2.12, LNM (Line Feed/New Line Mode) controls the interpretation of the line feed function.
- Set (newline mode) — When a LF (0x0A), VT (0x0B), or FF (0x0C) character is received, the cursor moves down one line and returns to the first column (as if a CR were also performed). Additionally, when the Return key is pressed, the terminal sends CR LF instead of just CR.
- Reset (line feed mode) — LF, VT, and FF only move the cursor down one line without changing the column position. The Return key sends only CR. This is the default.
LNM is an ANSI standard mode, not a DEC private mode. It uses CSI 20 h / CSI 20 l (without the ? prefix). This distinguishes it from DEC private modes which use the CSI ? prefix.
Bidirectional effect
LNM affects both directions of communication:
- Host to terminal — Controls whether received LF/VT/FF characters also imply CR
- Terminal to host — Controls whether the Return key sends CR alone or CR+LF
This bidirectional nature means that toggling LNM changes the behavior of both displayed output and keyboard input.
LNM was removed from ECMA-48 in the 5th edition (1991) because it was considered a host responsibility rather than a terminal function. Despite this, it remains widely supported by terminal emulators for backward compatibility.
Examples
printf '\e[20h' # Enable newline mode (LF implies CR)
printf '\e[20l' # Disable newline mode (LF only moves down)
Specifications
| Specification | Section |
|---|---|
| ECMA-48 | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | |
| Bobcat | ? | ? | Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code. |
| contour | ✓ | v0.3.0.198 | Implemented as AnsiMode::AutomaticNewLine at primitives.h:608, handled in Terminal.cpp:2251 |
| foot | ✗ | No | |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✗ | No | Explicitly not supported per source comment |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | MODE_NewLine controls LF behavior (also performs CR) |
| mintty | ✓ | Yes | Implemented at src/termout.c:2645 |
| mlterm | ✓ | rel-3_8_3 | Added with VTMODE_20 and auto_cr support |
| PuTTY | ✓ | 0.50 | |
| Rio | ✓ | v0.1.13 | |
| rxvt-unicode | ✓ | 3.7 | Newline mode via PrivMode_LFNL |
| st | ✓ | 0.1 | |
| terminology | ✓ | v0.4.0 | Uses termstate.crlf flag |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | |
| Windows Terminal | ✓ | Yes | LNM_LineFeedNewLineMode at adaptDispatch.cpp:1765-1773 |
| xterm | ✓ | Yes | ANSI line feed/newline mode |
| xterm.js | ✓ | 5.0.0 | |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✓ | v.4.2.0 | Present since at least v.4.0.2 (2005) |
| tmux | ✗ | No | MODE_CRLF flag exists internally but mode 20 is not accepted via SM/RM |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.31.4 | Handled in grid.rs:3019-3123, converts CR to CRLF when enabled |
See also
- LF — Line Feed — The line feed control character
- NEL — Next Line — Explicit next-line sequence (always does CR+LF)
- CR — Carriage Return — The carriage return control character