Skip to content

DEC Private Modes

DEC private mode sequences toggle terminal behaviors using DECSET (CSI ? Pm h) to enable and DECRST (CSI ? Pm l) to disable. The "?" prefix marks them as private (vendor-defined), separate from ECMA-48's standard mode numbers. Originally defined by DEC for the VT series, this namespace has been extended by xterm and other terminals. Key modes include: cursor visibility (DECTCEM, ?25), auto-wrap (DECAWM, ?7), alternate screen (?1049), mouse tracking (?1000–1006), bracketed paste (?2004), and focus events (?1004). DEC private modes are the primary mechanism for feature negotiation between applications and terminals. Some of the most important DEC private modes were invented decades after DEC itself ceased to exist — ?2004 (bracketed paste) was introduced by xterm in 2003 to prevent paste injection attacks, and has since become essential for every shell and editor.

30 features in this standard · Specification ↗

The DEC private mode protocol uses a simple symmetry: ESC [?Nh enables mode N, ESC [?Nl disables it. Applications are expected to restore modes they change — enabling mouse tracking on startup and disabling it on exit, for example. Failure to do this leaves the terminal in a broken state (the classic "mouse events printing garbage" problem).

The most essential modes for modern development: ?1049 switches to the alternate screen buffer (used by vim, less, htop — anything that takes over the screen and restores it on exit); ?2004 enables bracketed paste, wrapping pasted text in ESC [200~ / ESC [201~ markers so the application can distinguish typed input from pasted content; ?1000-1006 enable increasingly detailed mouse event reporting, from basic clicks (?1000) to pixel-precision motion tracking (?1003+?1006).

The private mode namespace has no central authority — DEC defined the low numbers, xterm extended into the thousands, and modern terminals keep allocating new ones. ?2026 (synchronized output) is one of the newest: it tells the terminal to buffer rendering until a complete frame is ready, eliminating flicker in rapid screen updates. Mode queries via DECRPM (ESC [?Ns$p) let applications discover which modes a terminal actually supports.

Analysis2026-04-06

DEC Private Modes defines 28 features in the terminfo.dev matrix. Average adoption across terminals: 92%. Full compliance (100%): xterm.js, Warp, Cursor, VS Code. Lowest: vt100.js at 54% (15/28).

Terminal Applications

Headless Backends

Parser correctness tested via Termless. A means the parser accepts the sequence, not that it renders correctly.