ANSI Escape Codes List Updated by Byron Stanoszek on August 7, 2001 Comments or additions may be sent to the author at gandalf@winds.org. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ASCII 0 Ignored 7 Alert Bell 8 Backspace 9 Tab 10 Carriage Return + Linefeed 11,12 Linefeed 13 Carriage Return 14 Invoke Character Set G1 15 Invoke Character Set G0 17 Start Transmit (XON) 19 Stop Transmit (XOFF) 24,26 Abort Escape Sequence 27 Enable Escape Sequence (ESC) 127 Delete 155 Enable CSI Sequence (8-bit only) ESC [ CSI Sequence, Equivalent to ASCII Character 155. Terminal Resets --------------- ESC c Hard Reset (Cold Boot) ESC [z Soft Reset (Warm Boot) ESC [!p Soft Reset (Warm Boot) Cursor Positioning ------------------ ESC [#G Jump to column # ESC [#` Jump to column # ESC [#d Jump to row # ESC [#A Cursor Up # ESC [#B Cursor Down # ESC [#C Cursor Right # ESC [#D Cursor Left # ESC [#E Cursor Down #, Beginning of Line ESC [#F Cursor Up #, Beginning of Line ESC [#;#H Jump to Row# Column# ESC [#;#f Jump to Row# Column# ESC [#a Cursor Right # ESC [#e Cursor Down # ESC H Set tab stop at cursor column ESC [g Clear tab stop at cursor column ESC [3g Clear all tab stops ESC [#I Horizontal Tab # ESC [#Z Backward Tab # Character Erase --------------- ESC [J Erase from Cursor to End of Display ESC [1J Erase from Start of Display to Cursor ESC [2J Erase Whole Display ESC [K Erase from Cursor to End of Line ESC [1K Erase from Start of Line to Cursor ESC [2K Erase Whole Line ESC [#X Erase # Characters to the right of and including Cursor Insert/Delete ------------- ESC [#L Insert # Lines at Cursor Position. Screen scrolls down. ESC [#@ Insert # Characters at Cursor Position. Columns scroll right. ESC [#M Delete # Lines at Cursor Position. Screen scrolls up. ESC [#P Delete # Characters at Cursor Position. Columns scroll left. TTY Operations -------------- ESC D LF ESC E CRLF ESC M Reverse Index (Cursor moves up, screen scrolls down) ESC = Application Keypad ESC > Numeric Keypad ESC g Visual Alert Bell ESC [#;#;...#q Set Keyboard LEDs (0 = All LEDs Off, 1 to 4 = Turn LED On) Cursor Attribute Manipulation ----------------------------- ESC 7 Save Cursor Location & Attributes ESC 8 Restore Cursor Location & Attributes ESC [s Save Cursor Location & Attributes ESC [u Restore Cursor Location & Attributes Scroll Region ------------- ESC [#;#r Set Scroll Region from Rows # to # inclusive; send cursor home ESC [#S Scroll Scrolling Region Up ESC [#T Scroll Scrolling Region Down ESC [#^ Scroll Scrolling Region Down Character Sets -------------- ESC (# Change Character Set G0 to Mode # ESC )# Change Character Set G1 to Mode # ESC *# Change Character Set G2 to Mode # ESC +# Change Character Set G3 to Mode # Modes: A British, U.K. B ASCII, North American C Finnish E Danish, Norwegian H Swedish K German Q French Canadian R Flemish, French/Belgian U IBM PC Character Set Y Italian Z Spanish 0 Line Drawing 1 Alternative Character 2 Alternative Line drawing 4 Dutch 5 Finnish 6 Danish, Norwegian 7 Swedish < Latin Supplemental = Swiss (French or German) Default Modes: G0: A G1: 0 G2: < G3: 0 Default Graphics Sets: (GL = 0x20-0x7f, GR = 0x90-0xff) GL: G2 GR: G0 Invoke Character Sets --------------------- Ctrl-O Change GL to G0 Ctrl-N Change GL to G1 ESC n Change GL to G2 ESC o Change GL to G3 ESC N Change GL to G2 (Single Shift - Affects next character only) ESC O Change GL to G3 (Single Shift - Affects next character only) ESC ~ Change GR to G1 ESC } Change GR to G2 ESC | Change GR to G3 Character Cell Sizing --------------------- ESC #1 Double height, single width top half characters ESC #2 Double height, single width lower half characters ESC #3 Double height, double width top half characters ESC #4 Double height, double width lower half characters ESC #5 Single height, single width characters ESC #6 Single height, double width characters DEC Screen Adjust ----------------- ESC #8 Screen Alignment Test (fills screen with E's) Console Reports --------------- ESC [c Report primary device attributes ESC [>c Report secondary device attributes ESC [?1;#c Response, where # is sum of the following: 0 Base VT100, No Options +1 Preprocessor option (STP) +2 Advanced video option (AVO) +4 Graphics processor option (GO) VT220 response codes: ESC [?62;#;...#c Where # is: 1 132 Columns 2 Printer port 6 Selective erase 7 Soft character set 8 User defined keys ESC [5n Status report ESC [n "Terminal OK" response ESC [3n "Terminal Not OK" response ESC [6n Cursor position report ESC [#;#R Response in the form Line;Column ESC [x Send terminal parameter report; Response: ESC [3;parity;nbits;xspeed;rspeed;1;0x ESC Z TTY ID Check; Response same as ESC [c Console Modes ------------- ESC [#;#;...#h Set Modes [ON/ ]. ESC [#;#;...#l Set Modes [ /OFF]. Modes: ?1 [Application/ANSI] Cursor Keys ?2 [ANSI/VT52] Mode ?3 [132/80] Column Mode ?4 [Smooth/Jump] Scroll Rate ?5 [Reverse/Normal] Screen ?6 [Relative/Absolute] Cursor Positioning ?7 Auto wrap-around [On/Off] ?8 Keyboard Autorepeat [On/Off] ?9 Interlace [On/Off] ?14 [Immediate/Deferred] operation of Enter Key ?16 [Immediate/Deferred] edit selection ?18 Send [Form Feed/No Form Feed] after Print Screen ?19 Print Screen prints [Entire Screen/Scroll Region] ?22 Keyclick [Off/On] ?25 Cursor Visibility [On/Off] ?26 Bidirectional [Transparent/Copy] Print ?27 [Full/Half] Intensity ?30 [Lock/Unlock] Setup ?45 Reverse Wrap-around [On/Off] ?50 Cursor Visibility [On/Off] ?66 [Application/ANSI] Keypad Keys ?67 Backspace key generates [BS/DEL] ?75 Screen Display [On/Off] 2 [Lock/Unlock] Keyboard 3 Display Control Characters [On/Off] 4 Insert Mode [On/Off] 12 Echo [None/Local] 20 Newline Mode Does [CRLF/CR] System Configuration -------------------- ESC [2y Restore factory default settings (also ESC [2;0y) ESC [2;#y Invoke Self Test, # = Following Modes added together: 1 Power-up test 2 Data loopback 4 EIA modem control signal test 8 Repeat tests indefinitely ESC [0;#z 25th line: 0=blank, 1=status ESC [2;#z Screensaver Select, # = 0 to 12 ESC [3;#z Set cursor attributes ESC [4;#z Brightness Select, # = 0 to 30 Cursor Attributes ----------------- ESC [#;#;...;m Set Cursor Attribute Rendition Modes: 0 All Attributes Off 1 Intensity On 2 Half-Intensity On 3 Standout/Italics On 4 Underline On 5 Blinking On 6 Rapid Blinking On 7 Reverse Video Mode On 8 Invisible Text On 10 Select Primary 7-bit Font 11 Select IBM PC Control Display Font 12 Select IBM PC Ctrl+Meta Display Font 21 or 22 Normal Intensity 23 Standout/Italics Off 24 Underline Off 25 or 26 Blinking Off 27 Reverse Video Mode Off 28 Invisible Text Off 29 Clear Color Attributes 3x Set Foreground Color to x. Add Values 1=Red, 2=Green, 4=Blue. 4x Set Background Color to x. Add Values 1=Red, 2=Green, 4=Blue. 39 Restore Default Foreground Color 49 Restore Default Background Color I/O Codes --------- ESC 5 Send Data ESC #7 Print Screen ESC [i Print Screen ESC [5i Buffered transparent print ESC [?1i Print line under cursor ESC [?4i Disable auto-line print mode ESC [?5i Enable auto-line print mode ESC [?7i Buffered copy print ESC [?15n Report printer status ESC [?25n Report user-keys status ======================= Non-standard ANSI Codes ======================= Color Palette (Linux Only) ------------- ESC ]R Restore Default Color Palette ESC ]P####### Set Palette Colors: First # = Palette Color Index from 0 to F (hexadecimal). Second-third # = Red Index, from 00 to FF. Fourth-fifth # = Green Index, from 00 to FF. Sixth-seventh # = Blue Index, from 00 to FF. Linux Setterm Operations ------------------------ ESC [1;#] Set Color # for Underline Mode ESC [2;#] Set Color # for Half Intensity Mode ESC [8] Store Colors as Default ESC [9;#] Set Screen Blanking Interval (# Minutes) ESC [10;#] Set Bell Frequency # (Pitch) in Hz ESC [11;#] Set Bell Duration # in Msec ESC [12;#] Bring Console # to front ESC [13] Unblank Screen ESC [14;#] Set VESA Powerdown Interval (# Minutes) Xterm Operations ---------------- ESC [?1000h Turn Mouse click response on ESC [?1000l Turn Mouse click response off Mouse clicks send ESC [Mxyz where xyz are the following char codes plus 32: x = Mouse buttons. 0=Left, 1=Middle, 2=Right, 3=Button Depressed y = Column (begins at 1) z = Row (begins at 1) DOS (Ansi.sys) Specific ----------------------- ESC [#;#B Set frequency(Hz) and Duration(msec) for bell (Default 100;250) ESC [#F Set foreground color # as default (# = 0 to 15) ESC [#G Set background color # as default (# = 0 to 15) ESC [#;*;*...*p Remap ASCII key # to text *. * can be either ASCII character codes, control characters or strings enclosed in double quotes. SunView Specific ---------------- ESC [8;#;#t Resize window to # lines and # columns ======================= VT52 Compatibility Mode ======================= ESC A Cursor up ESC B Cursor down ESC C Cursor right ESC D Cursor left ESC F Select graphics character set ESC G Select ASCII character set ESC H Cursor home ESC I Reverse line feed ESC J Erase to end of screen ESC K Erase to end of line ESC V Print cursor line ESC W Print controller on ESC X Print controller off ESC Ylc Direct cursor address; l and c are single character codes whose values are the desired number plus 31 decimal. Line and column numbers begin at 1. ESC Z Identify; VT52 terminal responds with ESC /Z ESC ] Print screen ESC ^ Auto print on ESC _ Auto print off ESC 1 Graphics processor on ESC 2 Graphics processor off ESC < Enter ANSI Mode