Skip to main content

LNM

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

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)
Formal syntax
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.
note

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.

caution

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​

SpecificationSection
ECMA-48—

Terminal support​

TerminalSupportVersionNotes
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.198Implemented as AnsiMode::AutomaticNewLine at primitives.h:608, handled in Terminal.cpp:2251
foot✗No
Ghostty✓v1.0.0
iTerm2✗NoExplicitly not supported per source comment
Kitty✓Yes
Konsole✓YesMODE_NewLine controls LF behavior (also performs CR)
mintty✓YesImplemented at src/termout.c:2645
mlterm✓rel-3_8_3Added with VTMODE_20 and auto_cr support
PuTTY✓0.50
Rio✓v0.1.13
rxvt-unicode✓3.7Newline mode via PrivMode_LFNL
st✓0.1
terminology✓v0.4.0Uses termstate.crlf flag
VT100✓Yes
VTE✓Yes
WezTerm✓Yes
Windows Terminal✓YesLNM_LineFeedNewLineMode at adaptDispatch.cpp:1765-1773
xterm✓YesANSI line feed/newline mode
xterm.js✓5.0.0
Multiplexers
cy✓Yes
GNU Screen✓v.4.2.0Present since at least v.4.0.2 (2005)
tmux✗NoMODE_CRLF flag exists internally but mode 20 is not accepted via SM/RM
tuios✓v0.0.15
Zellij✓v0.31.4Handled in grid.rs:3019-3123, converts CR to CRLF when enabled

See also​