DECNCSM — No Clear Screen on column-mode change (`CSI ? 95 h / l`)
Suppress DECCOLM's (and DECSCPP's) implicit screen-clear side-effect. With DECNCSM set, switching between 80- and 132-column modes preserves cell contents instead of wiping them.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[?95h (set — preserve) \x1b[?95l (reset — clear)\033[?95h\e[?95hESC [ ? 9 5 h / ESC [ ? 9 5 l1b 5b 3f 39 35 68 / 6cDescription
DECNCSM — *No Clear Screen on column-mode change* — is the modifier mode that controls the clear-on-resize side-effect of `deccolm` (DEC 132-Column Mode, `?3h/l`) and `decscpp` (Select Columns Per Page, `CSI Pn $|`). **Reset (default, `\x1b[?95l`)** — DECCOLM and DECSCPP behave as historically specified: switching between 80- and 132-column modes **clears** the screen, homes the cursor, resets DECSTBM scrolling-region to full screen, and resets DECSLRM left/right margins. This is the original VT100 hardware behaviour — the CRT couldn't reflow text, so the screen was wiped. **Set (`\x1b[?95h`)** — DECCOLM / DECSCPP **preserve** cell contents on column-mode change. Cells outside the new width are dropped (or hidden in some implementations until a return to wider columns). DECSTBM and DECSLRM still reset; cursor is repositioned to fit the new geometry. This is the modern terminal-emulator-friendly default for users who want to widen / narrow without losing context. **Why this exists** — apps that need legacy DECCOLM behaviour (xterm running in `allowC132` mode for a VT220 conformance test) must clear; modern apps that want responsive resize (browser-style 'when the user toggles width, keep my buffer') want preserve. DECNCSM gives the application code the choice. Some users wire it to `?95h` permanently in their xterm resources (`*decTerminalID: vt320` + `*setColumnRequired: false`) for friendlier resize ergonomics. **Interaction with `deccolm` / `decscpp`**: - `\x1b[?95l` + `\x1b[?3h` → switch to 132-col mode, **screen cleared** (legacy). - `\x1b[?95h` + `\x1b[?3h` → switch to 132-col mode, **contents preserved**. - Same pairing applies to `\x1b[80$|` / `\x1b[132$|` (DECSCPP). **Important non-effect**: DECNCSM only suppresses the clear *from DECCOLM / DECSCPP*. RIS (`\x1bc`), DECSTR (`\x1b[!p` — see `decstr-side-effects`), and explicit ED (`\x1b[2J`) all still clear regardless of DECNCSM state. Don't reach for DECNCSM as a generic 'don't clear my screen' switch — it's specifically scoped to column-mode toggles. **Coverage**: **xterm** = full (the canonical implementation). **Kitty** / **WezTerm** / **Ghostty** = full. **iTerm2** = full. **Konsole** = full. **Windows Terminal** = partial (DECCOLM itself is gated by config, but when enabled DECNCSM is honoured ≥ 1.18). **Alacritty** = effectively no-op (DECCOLM is itself a no-op, so DECNCSM has nothing to gate). **Linux console** / **macOS Terminal** / **cmd / ConPTY** / **gnome-terminal** = no-op. **Query**: `\x1b[?95$p` (DECRQM — see `decrqm` / `decrpm-decoder`) — reply `\x1b[?95;1$y` if set, `\x1b[?95;2$y` if reset.
Spec citation: DEC VT510 RM (DECNCSM) / xterm-ctlseqs (CSI ? 95 h / l)
Examples
# Enable preserve-on-resize, then switch to 132 columns without losing buffer.\nprintf '\\033[?95h' # DECNCSM set — no clear on column-mode change\nprintf '\\033[?3h' # DECCOLM 132 col (with DECNCSM, contents survive)import sys\nsys.stdout.write('\\x1b[?95h') # don't clear on column toggle\nsys.stdout.write('\\x1b[132$|') # DECSCPP to 132 cols, preserving buffer\nsys.stdout.flush()// Persist DECNCSM at startup, restore at exit.\nfmt.Print(\"\\x1b[?95s\") // XTSAVE — push current value\nfmt.Print(\"\\x1b[?95h\") // enable preserve\ndefer fmt.Print(\"\\x1b[?95r\") // XTRESTORE on exit// Probe DECNCSM state before deciding whether to defensively redraw on resize.\nprocess.stdout.write('\\x1b[?95$p');\n// expect reply \\x1b[?95;1$y (set) or ?95;2$y (reset)/* Disable preserve (restore historical clear-on-DECCOLM). */\nprintf(\"\\x1b[?95l\");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- yes
- Windows Terminal
- partial
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- no
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- no
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | yes | partial | no | yes | no | yes | yes | no | yes | no | no |
Related sequences
- DECCOLM — 80 / 132 column mode (CSI ? 3 h / l)
- DECSCPP — Select columns per page (CSI Pn $ |)
- DECSTBM — Set Top/Bottom Margins (CSI r)
- DECSLRM — Set left and right margins (CSI Pl ; Pr s)
- DECRQM — Request Mode Status (CSI ? Ps $ p)
- XTSAVE / XTRESTORE — Save / restore DEC private mode (`CSI ? Pm s` / `CSI ? Pm r`)