Christian recently show me that \x0c was the hex code of ctrl-l
How can I compute the code of those sorts of keys'combination as ctrl-
i etc....
Thank you
Well ctrl+A through ctrl+Z are sequentially \x01 through \x1a
while the remainder are a bit more hodgepodge such as <esc> =
ctrl+[ = \x1b
-tim
I usually do ga on the character
:h ga
regards,
Christian
Easiest is probably:
i<C-v>(char)<ESC>ga
Stepwise, that's:
i - enter insert mode
<C-v> - enter literal character [ :help i_CTRL-V ]
(char) - type whatever character you want (e.g. ctrl-i)
<ESC> - exit insert mode
ga - get ASCII value [ :help ga ]
For ctrl-i for example, the bottom of the screen reads:
<^I> 9, Hex 09, Octal 011
(Ctrl-i is synonymous with <Tab>)
--
Best,
Ben
I made an ASCII chart that I printed.
Control ========================================================
Dec Oct Hex Abbr CS CEC 'vim' Description
0 000 00 NUL ^@ \0 \%x00 Null character (only 'vim')
1 001 01 SOH ^A \%x01 Start of Header
2 002 02 STX ^B \%x02 Start of Text
3 003 03 ETX ^C \%x03 End of Text
4 004 04 EOT ^D \%x04 End of Transmission
5 005 05 ENQ ^E \%x05 Enquiry
6 006 06 ACK ^F \%x06 Acknowledgment
7 007 07 BEL ^G \a \%x07 Bell (only 'vim')
8 010 08 BS ^H \b \%x08 Backspace
9 011 09 HT ^I \t \%x09 Horizontal Tab
10 012 0A LF ^J \n \%x0A Line Feed
11 013 0B VT ^K \v \%x0B Vertical Tab (only 'vim')
12 014 0C FF ^L \f \%x0C Form Feed (only 'vim')
13 015 0D CR ^M \r \%x0D Carriage Return
14 016 0E SO ^N \%x0E Shift Out
15 017 0F SI ^O \%x0F Shift In
16 020 10 DLE ^P \%x10 Data Link Escape
17 021 11 DC1 ^Q \%x11 Device Control 1 XON
18 022 12 DC2 ^R \%x12 Device Control 2
19 023 13 DC3 ^S \%x13 Device Control 3 XOFF
20 024 14 DC4 ^T \%x14 Device Control 4
21 025 15 NAK ^U \%x15 Negative Acknowledgement
22 026 16 SYN ^V \%x16 Synchronous Idle
23 027 17 ETB ^W \%x17 End of Transmission Block
24 030 18 CAN ^X \%x18 Cancel
25 031 19 EM ^Y \%x19 End of Medium
26 032 1A SUB ^Z \%x1A Substitute
27 033 1B ESC ^[ \e \%x1B Escape
28 034 1C FS ^\ \%x1C File Separator
29 035 1D GS ^] \%x1D Group Separator
30 036 1E RS ^^ \%x1E Record Separator
31 037 1F US ^_ \%x1F Unit Separator
127 177 7F DEL ^? \%x7F Delete
Printable ======================================================
Dec Oct Hex Glyph Dec Oct Hex Glyph Dec Oct Hex Glyph
32 040 20 64 100 40 @ 96 140 60 `
33 041 21 ! 65 101 41 A 97 141 61 a
34 042 22 " 66 102 42 B 98 142 62 b
35 043 23 # 67 103 43 C 99 143 63 c
36 044 24 $ 68 104 44 D 100 144 64 d
37 045 25 % 69 105 45 E 101 145 65 e
38 046 26 & 70 106 46 F 102 146 66 f
39 047 27 ' 71 107 47 G 103 147 67 g
40 050 28 ( 72 110 48 H 104 150 68 h
41 051 29 ) 73 111 49 I 105 151 69 i
42 052 2A * 74 112 4A J 106 152 6A j
43 053 2B + 75 113 4B K 107 153 6B k
44 054 2C , 76 114 4C L 108 154 6C l
45 055 2D - 77 115 4D M 109 155 6D m
46 056 2E . 78 116 4E N 110 156 6E n
47 057 2F / 79 117 4F O 111 157 6F o
48 060 30 0 80 120 50 P 112 160 70 p
49 061 31 1 81 121 51 Q 113 161 71 q
50 062 32 2 82 122 52 R 114 162 72 r
51 063 33 3 83 123 53 S 115 163 73 s
52 064 34 4 84 124 54 T 116 164 74 t
53 065 35 5 85 125 55 U 117 165 75 u
54 066 36 6 86 126 56 V 118 166 76 v
55 067 37 7 87 127 57 W 119 167 77 w
56 070 38 8 88 130 58 X 120 170 78 x
57 071 39 9 89 131 59 Y 121 171 79 y
58 072 3A : 90 132 5A Z 122 172 7A z
59 073 3B ; 91 133 5B [ 123 173 7B {
60 074 3C < 92 134 5C \ 124 174 7C |
61 075 3D = 93 135 5D ] 125 175 7D }
62 076 3E > 94 136 5E ^ 126 176 7E ~
63 077 3F ? 95 137 5F _
-Bill
You already got several answers about how to find it by experiment. Now
here is the rule, for Ctrl and/or Alt and a printable ASCII key. (I
regard Shift + <key> as a different key, to which the following also
applies.)
- Ctrl + ? = 0x7F (DEL)
- If 0x40 <= <key> <= 0x5F, then
Ctrl + <key> = <key> - 0x40
- If "a" <= <key> <= "z", then
Ctrl + <key> = Ctrl + Shift + <key> = <key> - 0x60
- If 0 <= <key> <= 0x7F (where <key> may include a Ctrl modifier) then
Alt + <key> = <key> + 0x80
Note that Alt is case-sensitive (Alt-A is not the same as Alt-a) but
Ctrl isn't (Ctrl-A = Ctrl-a = 0x01).
For printable keys other than 0x40 to 0x5F, a to z, and ?, Ctrl + <key>
is unspecified (may give different results, or nothing, from OS to OS).
For printable keys other than 0x00 to 0x7F, Alt + <key> is unspecified.
On some systems, Alt + <key> gives <Esc> followed by <key> instead. When
Vim can identify that the Esc is actually an Alt modifier, it stores it
as above, by setting the high bit. (See also :help 'timeout', :help
'ttimeout', :help 'timeoutlen', :help 'ttimeoutlen', :help :map-alt-keys)
The above says nothing about what a modifier does to a non-printable
key. The results vary from OS to OS and, within a single OS, from one
terminal to another (with a different termcap entry).
The above explains the following synonym pairs:
Ctrl-I and Tab (0x09)
Ctrl-M and Enter (0x0D)
Ctrl-[ and Esc (0x1B)
and also quite a lot of pairs between Alt-something and accented Latin1.
Best regards,
Tony.
--
Worst Vegetable of the Year:
The brussels sprout. This is also the worst vegetable of next
year.
-- Steve Rubenstein