> On Sat, April 2, 2011 6:14 am, Jean-Rene David wrote:
>> * wei gao [2011.04.01 02:40]:
>>> I want to add ";" to the end of line when coding. So, I add the
>>> following
>>> map in vimrc. however, it's not working for me (if I change to<C-e>,
>>> it's
>>> OK). Anybody know why?<C-;> is mapped to a special command already?
>>>
>>> :inoremap<C-;> <C-o>A;
>>
>> While you may see things like<C-e> or<C-]> as a sequence of keys, vim
>> actually gets those as a single character. These characters are *typed*
>> using a combination of the control key and another key on your keyboard
>> but when they actually reach vim they are one character.
>>
>> The set of these so called "control characters" are the first 32 ASCII
>> values (namely 0x00 to 0x1F in hex). You can map each control character
>> (which are "unprintable" characters) to a printable character used to
>> enter it on the keyboard. You do this by adding 0x40 to the value of the
>> control character like this:
>>
>> 0x00 =<C-@> maps to 0x40 = @
>> 0x01 =<C-A> maps to 0x41 = A
>> 0x02 =<C-B> maps to 0x42 = B
>> 0x03 =<C-C> maps to 0x43 = C
>> ...
>> 0x1A =<C-Z> maps to 0x5A = Z
>> 0x1B =<C-[> maps to 0x5B = [
>> 0x1C =<C-\> maps to 0x5C = \
>> 0x1D =<C-]> maps to 0x5D = ]
>> 0x1E =<C-^> maps to 0x5E = ^
>> 0x1F =<C-_> maps to 0x5F = _
>>
>> And that's it. There are no others.
Actually, there is one other, the DEL character, also unprintable but at
the other end of 7-bit US-ASCII: 0x7F = <C-?> maps to 0x3F = ?
ASCII comes historically from papertape codes: on 7-track papertape, you
would correct an error by overpunching a 0x7F "rubout" character (a hole
in every track) over the wrong punch; the receiving teletypewriter would
print nothing for that character, and also not advance the printing
carriage.
You could generalize your rule by saying that the Ctrl key toggles
(inverts) bit 0x40 when it is typed together with a key in the range
0x3F to 0x5F inclusive.
In addition, Ctrl + lowercase is the same as Ctrl + uppercase so you
don't have to hold Shift down when typing Ctrl-A, Ctrl-B, ..., Ctrl-Z.
>>
>> So, long story short, the reason you can't map<C-;> is that there is no
>> such character.
>
> For the record, this is also covered briefly in the FAQ:
> http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.5
>
> regards,
> Christian
>
Best regards,
Tony.
--
Nihilism should commence with oneself.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment