Skip to main content
ansicode

DECSTR — Soft terminal reset

Reset DEC private modes and SGR to defaults WITHOUT clearing the screen or scrollback.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[!p
\\033[\033[!p
\\e[\e[!p
ESC [ESC [ ! p
hex1b 5b 21 70

Description

DEC Soft Terminal Reset. Standard CSI with an intermediate `!` (0x21) before the final `p` (0x70). Restores: SGR (colour + attributes), auto-wrap (`?7`), insert/replace mode, scrolling region (DECSTBM), keyboard mode, character sets. Does NOT clear the screen, the scrollback, or the alt-screen state — making it the safe recovery path when a TUI crashed without restoring its SGR / auto-wrap / cursor state but you still want to keep your scrollback. Compare RIS (`\x1bc`) which is the hard reset and wipes scrollback.

Spec citation: xterm-ctlseqs (DECSTR, CSI ! p)

Examples

bash
printf '\033[!p'   # soft reset; scrollback preserved
python
import sys; sys.stdout.write('\x1b[!p')
go
fmt.Print("\x1b[!p")
javascript
process.stdout.write('\x1b[!p')
c
printf("\x1b[!p");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
partial
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

ESC cookbook · 1. Hard reset vs. soft reset — `\x1bc` (RIS) and `\x1b[!p` (DECSTR)