next up previous contents
Next: Deleting Characters, Lines and Up: Guide to VI and Previous: Command Mnemonics

Insert ASCII Control Characters in Text

It is possible to insert ASCII Control Characters while editing test with the insert, append, replace or substitute commands. Some Control Characters are inserted directly by typing <ctrl>x:
<ctrl>G bell
<ctrl>L form feed

Be careful: <ctrl>x can operate directly as editor command (i.e. <ctrl>[ operates insert break). If we want to insert a visible <esc>, we must use: <ctrl>V followed by <esc>. The full set of vi supported control characters is listed in the following table.


ASCII TABLE for SPECIAL CODES in vi
Dec Oct Hex Symbol vi Display Keypress
000 000 00 NULL none <ctrl><shift>@
001 001 01 SOH ^A <ctrl>A
002 002 02 STX ^B <ctrl>B
003 003 03 ETX ^C <ctrl>C
004 004 04 EOT ^D <ctrl>D
005 005 05 ENQ ^E <ctrl>E
006 006 06 ACK ^F <ctrl>F
007 007 07 BEL ^G <ctrl>G
008 010 08 BS ^H <ctrl>H
009 011 09 HT TAB <ctrl>I
010 012 0A LF <LF> <ctrl>J
011 013 0B VT <VT> <ctrl>K
012 014 0C FF <FF> <ctrl>L
013 015 0D CR <CR> <ctrl>M
014 016 0E SO ^N <ctrl>N
015 017 0F SI ^O <ctrl>O
016 020 10 DLE ^P <ctrl>P
017 021 11 DC1 ^Q <ctrl>Q
018 022 12 DC2 ^R <ctrl>R
019 023 13 DC3 ^S <ctrl>S
020 024 14 DC4 ^T <ctrl>T
021 025 15 NAK ^U <ctrl>U
022 026 16 SYN ^V <ctrl>V
023 027 17 ETB ^W <ctrl>W
024 030 18 CAN ^X <ctrl>X
025 031 19 EM ^Y <ctrl>Y
026 032 1A SUB ^Z <ctrl>Z
027 033 1B ESC ^[ <ctrl><esc>
028 034 1C FS ^\ <ctrl>V\
029 035 1D GS ^] <ctrl><shift>]
030 036 1E RS ^^ <ctrl><shift>^
031 037 1F US ^_ <ctrl><shift>_
127 177 7F DEL ~ <ctrl>V<del>


As an example of <esc> sequence editing for special terminal setup, let us consider the following fragment that produces a line in bold reverse video with magenta color. The first 4 lines contain only printable characters and decribe the escape sequences required to produce the wanted video aspect. At end is the line with the real <esc> code entered by <ctrl>v that prints the ^ (caret) immediately followed by <esc> that is printed as [.


Typing Escape Sequences
<ESC>[1m bold
<ESC>[7m reverse
<ESC>[35m magenta
<ESC>[0m reset to black
---------------------------
 
^[[1m^[[7m^[[35m Bold Reverse Magenta ^[[0m



next up previous contents
Next: Deleting Characters, Lines and Up: Guide to VI and Previous: Command Mnemonics
Marisa Luvisetto
2000-12-20