DECAWM
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
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
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
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Line wrap mode |
| Bobcat | ? | ? | Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code. |
| contour | ✓ | v0.1.0 | DECAWM (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 | ✓ | Yes | Auto-wrap mode |
| Ghostty | ✓ | v1.0.0 | Auto-wrap mode, enabled by default |
| iTerm2 | ✓ | Yes | Auto-wrap mode via wraparoundMode property |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | Auto-wrap at end of line (MODE_Wrap) |
| mintty | ✓ | Yes | DECAWM (Mode 7) auto-wrap implemented at src/termout.c:2421-2424 |
| mlterm | ✓ | Yes | Fundamental VT100 mode, present since early versions |
| PuTTY | ✓ | 0.45 | Auto-wrap mode at terminal.c:3103-3107 |
| Rio | ? | ? | |
| rxvt-unicode | ✓ | 1.2 | PrivMode_Autowrap - Auto-wrap |
| st | ✓ | 0.1 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | DEC_AUTOWRAP mode |
| WezTerm | ✓ | 20200202-181957-765184e5 | Auto-wrap at end of line |
| Windows Terminal | ✓ | Yes | |
| xterm | ✓ | xterm-1 | DECAWM (mode 7) - Auto-wrap at end of line |
| xterm.js | ✓ | 0.10 | Auto-wrap mode |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✓ | v.4.2.0 | Auto-wrap mode (src/ansi.c:1116-1118) |
| tmux | ✓ | 1.8 | |
| tuios | ✓ | v0.0.15 | Auto-wrap mode (ModeAutoWrap) |
| Zellij | ✓ | v0.31.2 | |
See also
- Reverse Wrap — Mode 45 — Wrapping in the reverse direction (backspace)
- DECSC/DECRC — Save/Restore Cursor — Saves DECAWM state