Standard ANSI Sequences

Control Characters

Sequence Hex-Code Description
\r 0D Carriage Return (CR) - Return to beginning of line
\n 0A Line Feed (LF) - Go to next line
  0C Form Feed (FF) - Same effect as LF
  0B Vertical Tab (VT) - Same effect as LF
\b 08 Backspace (BS) - Go back one character
\t 09 Horizontal Tab (HT) - Go to next tabulator position
\e 1B Escape (ESC) - Start of ANSI sequence

Attribute Sequences

Sequence Description
\e [ m Set bold, underline and inverse mode off
\e [ 0 m Set bold, underline and inverse mode off
\e [ 1 m Set bold mode on
\e [ 4 m Set underline mode on
\e [ 7 m Set invert mode on

Display Control Sequences

Sequence Description
\e [ 2 J Clear Display
\e [ K Erase to end of line
\e [ 0 K Erase to end of line

Cursor Control Sequences

Sequence Description
\e [ <n> A Cursor up <n> rows
\e [ <n> B Cursor down <n> rows
\e [ <n> C Cursor right <n> columns
\e [ <n> D Cursor left <n> columns
\e [ <x> ; <y> H Go to <x> <y> position
\e [ <x> ; <y> f Go to <x> <y> position
\e [ H Go to home (set cursor to x=0 / y=0)
\e [ f Go to home (set cursor to x=0 / y=0)
\e [ 6 n Get cursor position as \e [ <x> ; <y> R

Please note, that <x> <y> is used in the opposite order to that in standard ANSI sequences.

Save Restore Sequences

Sequence Description
\e [ <n> s Save cursor & attributes to memory position <n> (0 ... 7)
\e [ s Save cursor & attributes to memory position 0
\e [ <n> u Restore cursor & attributes from memory position <n> (0 ... 7)
\e [ u Restore cursor & attributes from memory position 0

See also:

Private ANSI Extensions