Escape sequence table
A reference table of common VT100, VT220 and xterm sequences: cursor, erase, style, modes and OSC.
A working reference of the sequences terminals handle most. Read Escape sequences first for the basics. ESC is byte 1B; n, m, row and col are numbers.
Cursor
ESC [ n A up n lines (CUU)
ESC [ n B down n lines (CUD)
ESC [ n C right n columns (CUF)
ESC [ n D left n columns (CUB)
ESC [ n E to the start of the line n lines down
ESC [ n F to the start of the line n lines up
ESC [ n G to column n
ESC [ row;col H move to row and column (CUP). 1 is the first
ESC 7 save cursor (DECSC)
ESC 8 restore cursor (DECRC)
ESC [ s / u save / restore cursor (ANSI.SYS style)
Erase and edit
ESC [ 0 J erase from cursor to end of screen
ESC [ 1 J erase from start of screen to cursor
ESC [ 2 J erase the whole screen
ESC [ 0 K erase from cursor to end of line
ESC [ 1 K erase from start of line to cursor
ESC [ 2 K erase the whole line
ESC [ n L insert n lines
ESC [ n M delete n lines
ESC [ n P delete n characters
ESC [ n @ insert n blank characters
ESC [ n X erase n characters
Scrolling
ESC [ top;bottom r set the scroll region (DECSTBM)
ESC [ n S scroll up n lines
ESC [ n T scroll down n lines
ESC D index (down one line, scroll at bottom)
ESC M reverse index (up one line, scroll at top)
Text style (SGR: ESC [ ... m)
0 reset all 1 bold 2 dim
3 italic 4 underline 5 blink
7 reverse video 8 hidden 9 strikethrough
22 normal intensity 23 not italic 24 not underlined
27 not reversed
30-37 foreground color (black red green yellow blue magenta cyan white)
90-97 bright foreground
40-47 background color 100-107 bright background
39 default foreground 49 default background
38;5;n foreground, color n of 256
48;5;n background, color n of 256
38;2;r;g;b foreground, true color
48;2;r;g;b background, true color
Modes (ESC [ ? n h to set, ESC [ ? n l to reset)
1 application cursor keys (arrows send ESC O A and so on)
7 wrap long lines
12 blinking cursor
25 show the cursor
1000 report mouse button presses
1002 report mouse drag
1003 report all mouse motion
1004 report focus in and out
1006 mouse reports in SGR format (works for wide screens)
1049 alternate screen with saved cursor
2004 bracketed paste
OSC (operating system command)
ESC ] 0 ; text BEL set the window title and icon name
ESC ] 2 ; text BEL set the window title
ESC ] 8 ; ; url ST start or end a hyperlink
BEL is byte 07. ST (string terminator) is ESC \. Not all terminals support every OSC.
Identify and reset
ESC [ c primary device attributes (DA): "who are you?"
ESC [ 6 n report the cursor position
ESC c full reset (RIS)
For the full list see the xterm control sequences document in VT and terminal links.