Skip to main content

DECAWM

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

DECAWM (Mode 7) is a DECSET/DECRST mode that controls whether characters written past the right margin automatically wrap to the beginning of the next line.

Syntax​

CSI ? 7 h    DECSET — Enable auto-wrap
CSI ? 7 l DECRST — Disable auto-wrap
Formal syntax
DECSET-mode7 = 0x1b, "[", "?", "7", "h" ;
DECRST-mode7 = 0x1b, "[", "?", "7", "l" ;

Description​

Per the VT100 User Guide and VT510 Programmer Reference, DECAWM controls the behavior when a character is written to the last column of the current line.

  • Set (auto-wrap on) — When a character is received while the cursor is at the right margin, the cursor wraps to the first column of the next line. If the cursor is on the bottom line of the scrolling region, the screen scrolls up by one line. This is the default on most modern terminals.
  • Reset (auto-wrap off) — When a character is received while the cursor is at the right margin, subsequent characters overwrite the last column position. The cursor does not advance to the next line.

Deferred wrap (pending wrap state)​

Most terminals implement a "deferred" or "pending" wrap mechanism. When a character is printed in the last column, the cursor does not immediately move to the next line. Instead, the terminal enters a "pending wrap" state. The wrap occurs only when the next printable character is received. This allows the last column to be written without triggering an unwanted blank line.

This subtle behavior means that after writing to the last column:

  • A cursor movement sequence (CUP, CUF, etc.) clears the pending wrap state without wrapping
  • The next printable character triggers the wrap and is placed in column 1 of the next line
note

DECAWM is saved and restored by DECSC/DECRC (ESC 7 / ESC 8).

Examples​

printf '\e[?7h'      # Enable auto-wrap (default on most terminals)
printf '\e[?7l' # Disable auto-wrap

# With auto-wrap disabled, overwrite the last column repeatedly
printf '\e[?7l'
printf '\e[1;80H' # Move to last column
printf 'ABCDE' # Only 'E' is visible in the last column
printf '\e[?7h' # Re-enable auto-wrap

Specifications​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesLine wrap mode
Bobcat??Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code.
contour✓v0.1.0DECAWM (mode 7 - auto wrap) implemented as DECMode::AutoWrap in primitives.h lines 676-676, set via Terminal.cpp line 2486, checked in Screen.cpp line 387
foot✓YesAuto-wrap mode
Ghostty✓v1.0.0Auto-wrap mode, enabled by default
iTerm2✓YesAuto-wrap mode via wraparoundMode property
Kitty✓Yes
Konsole✓YesAuto-wrap at end of line (MODE_Wrap)
mintty✓YesDECAWM (Mode 7) auto-wrap implemented at src/termout.c:2421-2424
mlterm✓YesFundamental VT100 mode, present since early versions
PuTTY✓0.45Auto-wrap mode at terminal.c:3103-3107
Rio??
rxvt-unicode✓1.2PrivMode_Autowrap - Auto-wrap
st✓0.1
terminology✓v0.1.0
VT100✓Yes
VTE✓YesDEC_AUTOWRAP mode
WezTerm✓20200202-181957-765184e5Auto-wrap at end of line
Windows Terminal✓Yes
xterm✓xterm-1DECAWM (mode 7) - Auto-wrap at end of line
xterm.js✓0.10Auto-wrap mode
Multiplexers
cy✓Yes
GNU Screen✓v.4.2.0Auto-wrap mode (src/ansi.c:1116-1118)
tmux✓1.8
tuios✓v0.0.15Auto-wrap mode (ModeAutoWrap)
Zellij✓v0.31.2

See also​