Reverse wrap
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
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:
- Mode 45 (reverse wraparound) is enabled
- 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.
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
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✗ | No | |
| Bobcat | ✓ | 0.9.0 | Implemented in TerminalCtrl library. Configurable via ReverseWrap setting. |
| contour | ✗ | No | Explicitly marked as TODO at primitives.h:879 |
| foot | ✓ | Yes | |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✗ | No | |
| Konsole | ✗ | No | |
| mintty | ✓ | Yes | Implemented at src/termout.c:2425 |
| mlterm | ✗ | No | Permanently reset (never enabled) according to get_vtmode() |
| PuTTY | ✗ | No | |
| Rio | ✗ | No | |
| rxvt-unicode | ✗ | No | Commented as 'margin bell NYI' in source |
| st | ✗ | No | |
| terminology | ✗ | No | Marked as TODO at line 414 in termptyesc.c |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | |
| Windows Terminal | ✗ | No | No implementation found in codebase |
| xterm | ✓ | 380 | Original 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
- DECAWM — Auto-Wrap Mode — Required for reverse wrap to function
- BS — Backspace — The backspace control character affected by this mode