Skip to main content
ansicode

DL — Delete Line (CSI Pn M)

Remove N lines starting at the cursor row and pull subsequent lines up within the scrolling region — vim's 'dd' command primitive.

Byte forms

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

\\x1b[\x1b[PnM
\\033[\033[PnM
\\e[\e[PnM
ESC [ESC [ Pn M
hex1b 5b <Pn> 4d

Description

Delete Line. Final byte M (0x4d) removes Pn lines starting at the cursor row (default 1); every line below them inside the active scrolling region (DECSTBM) is pulled upward by Pn, and Pn fresh blank lines appear at the bottom of the region with the current SGR background. Cursor moves to column 1 of its row (same xterm-vs-spec column-reset behaviour as IL). DL is the primitive vim's dd command emits, what less uses to scroll a line at the top off-screen, and what tmux's pane resize relies on. Counterpart is IL (\x1b[Pn L); used together with \x1b[T;Br (DECSTBM) you get atomic small-region scrolls without redrawing the whole screen. Terminfo cap: dl1 (Pn=1) or dl (parameterised).

Spec citation: ECMA-48 §8.3.32 (DL)

Examples

bash
# Set scroll region rows 1..5, position cursor at row 2, delete 1 line.\nprintf '\033[1;5r\033[2;1H\033[1M'
python
import sys; sys.stdout.write('\x1b[1M')
go
fmt.Print("\x1b[1M")
javascript
process.stdout.write('\x1b[1M')
c
printf("\x1b[1M");

Used in

Real-world tools that emit this sequence — anchors the bytes to commands you've already used.

  • vim, neovim — `dd` (delete line) primitiveevery `dd` / `d<motion>` that removes whole lines compiles down to `\x1b[<N>M` at the start row inside the DECSTBM region — the lines below visibly pull up without the editor having to repaint each remaining row
  • less, more — scroll-down past top lineevery forward-scroll step emits `\x1b[<N>M` at row 1 to slide the top N lines off-screen; new tail lines are then written into the blanks IL/DL leaves at the bottom of the page region
  • ncurses — `deleteln()` / `wdeleteln()`libncurses' `deleteln(WIN)` lowers directly onto `dl1` / `dl` terminfo caps — any program that scrolls a region by repeatedly emitting `dl` (top, irssi, tmux's own status pop-up) re-uses DL via this API rather than touching the bytes
  • tmux status-line redraw, copy-mode prompt cleartmux's bottom status line and copy-mode prompt are drawn inside a 1-row DECSTBM region — clearing them is a single `\x1b[1M` instead of a full-row repaint, which keeps redraws under 1 ms even at 240 Hz refresh
  • irssi, weechat, glirc — IRC backscroll trimmingwhen an IRC backlog hits the visible cap, the TUI emits `\x1b[<N>M` at the chat region's top row to drop the oldest N lines — fresher messages then write into the blanks DL leaves at the bottom, no global repaint

Frequently asked

Short answers to the questions developers actually search for this sequence.

What's the difference between \x1b[M (DL) and \x1b[K (EL)?
DL (\x1b[Pn M) deletes Pn whole rows starting at the cursor — subsequent rows shift up to fill the gap, and blank rows appear at the bottom of the scroll region. EL (\x1b[Pn K) erases characters *within the current row* — \x1b[0K clears from cursor to end-of-line, \x1b[1K from start to cursor, \x1b[2K the whole row. EL leaves the row in place (still visible, just blank); DL removes the row entirely and the following rows scroll up. Use EL to repaint a status line; use DL to drop a completed log entry.
Does \x1b[M move the cursor?
No. After DL the cursor stays on the same row (and at the same column) — what changed is the *content* of that row, which now holds whatever was on the row immediately below before the operation. ECMA-48 §8.3.32 specifies cursor position is unchanged. Watch the visual confusion: DL deletes the row at the cursor, but because the rows below scroll up, it *looks* like the cursor moved down to consume the next row. Mentally model DL as 'delete this row, everything below comes up by one' — not 'the cursor advances'.

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
yes
GNU screen
yes

Related sequences

In the family cookbook

CSI cookbook · 6. Insert / delete / cursor shape — IL / DL / ICH / DCH / ECH + DECSCUSR