Skip to main content

Reverse wrap

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!
Experimental

Reverse Wrap (Mode 45) is a DECSET/DECRST mode that controls whether a backspace at the beginning of a line wraps the cursor to the end of the previous line.

Syntax​

CSI ? 45 h    DECSET — Enable reverse wraparound
CSI ? 45 l DECRST — Disable reverse wraparound
Formal syntax
DECSET-mode45 = 0x1b, "[", "?", "4", "5", "h" ;
DECRST-mode45 = 0x1b, "[", "?", "4", "5", "l" ;

Description​

Mode 45 is an XTerm extension that enables reverse wraparound. When a backspace (BS, 0x08) is received while the cursor is at the first column, this mode controls whether the cursor wraps to the last column of the previous line.

  • Set (reverse wrap on) — A backspace at column 1 moves the cursor to the last column of the previous line. If the cursor is at the top-left corner of the screen (or scrolling region), the backspace has no effect.
  • Reset (reverse wrap off) — A backspace at column 1 has no effect; the cursor stays at column 1. This is the default.

Requirements​

Reverse wrap only occurs when both of the following conditions are met:

  1. Mode 45 (reverse wraparound) is enabled
  2. DECAWM (Mode 7, auto-wrap) is also enabled

If auto-wrap is disabled, reverse wrap has no effect regardless of Mode 45.

Scope​

Reverse wrap only applies to the BS (backspace) control character. Cursor movement sequences like CUB (CSI D) do not wrap regardless of this mode; they stop at column 1.

note

XTerm also supports Mode 1045, which is a variant that interacts differently with the alternate screen buffer. Mode 45 is the more commonly implemented variant.

Examples​

printf '\e[?7h'      # Enable auto-wrap (required for reverse wrap)
printf '\e[?45h' # Enable reverse wraparound
printf '\e[?45l' # Disable reverse wraparound

Specifications​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗No
Bobcat✓0.9.0Implemented in TerminalCtrl library. Configurable via ReverseWrap setting.
contour✗NoExplicitly marked as TODO at primitives.h:879
foot✓Yes
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✗No
Konsole✗No
mintty✓YesImplemented at src/termout.c:2425
mlterm✗NoPermanently reset (never enabled) according to get_vtmode()
PuTTY✗No
Rio✗No
rxvt-unicode✗NoCommented as 'margin bell NYI' in source
st✗No
terminology✗NoMarked as TODO at line 414 in termptyesc.c
VT100✗No
VTE✓Yes
WezTerm✓Yes
Windows Terminal✗NoNo implementation found in codebase
xterm✓380Original mode 45 implemented in patch 380, extended mode 1045 in patch 383
xterm.js✓4.6.0
Multiplexers
cy✗No
GNU Screen✗No
tmux✗No
tuios✗No
Zellij✗No

See also​