
The former can cause Vim to leave insert mode (because of the escape), the latter can break encoding (that is, collides with latin1 or whatever characters, or starts an utf-8 sequence) Specifically on disabling control keyīecause you can map characters, one option is to map every character that results from modifying a typed character with a control key to a nop, as in map Another is to treat it as a modifier that sets bit 8.


Popular methods are to send an escape char followed by the key pressed with alt (complete with shift processing).
#DISABLE CTRL COMMANDS HYPERTERM HOW TO#
Many GUI terminal emulators have configuration options on how to handle this. There aren't other characters in ASCII left to reference.
#DISABLE CTRL COMMANDS HYPERTERM CODE#
Another interesting one on my system is that ctrl+4 is equal to ^\, and control+\ is the code to terminate (vs ctrl+c to interrupt) the running program.Īlt/meta is another issue. I don't know the reasoning behind the others, such as for null or ^^ for 0x1E (often typed as ctrl+6 regardless of where the ^ key is on your keyboard). This doesn't cover all 31 control characters though. This allows a printable representation of an unprintable character. For example, a literal bel character in a file opened by Vim will be displayed as ^G.

To designate that it is a representation of a control key, a ^ is placed before it. Since there is no upper or lowercase with control (the shift clearing bit is included with control), and keyboard keys are usually shown in upper-case, and old systems didn't have lower case anyway, the convention is showing uppercase. This is why ctrl+m and enter are mapped the same time in Vim they are the same character. 'm' with the control key gets converted from 0圆D to 0xD which is carraige return, which is also what the Enter key sends. The control key is another modifier, which instead of clearing bit 5 while held down, clears bits 5 and 6 (0圆0), so 'a' goes from 0圆1 to just 0x1 which is ASCII start of header. I think the actual progression was different). (this is a convenient way of thinking about it at anyrate. In the case of letters, the modification is to remove the 5th bit (0x20), so 'a' being 0圆1 becomes 'A' at 0x41, and 'z' being 0x7A becomes 'Z' at 0x5A. What is considered to be happening under-the-hood is that holding shift modifies the next key. Shift+letter goes through as the upper case letter. Lower case letters go through as the lower case letter. Numbers and symbols send the ASCII code for that number or symbol. The way this usually works are that the printing characters are sent like you'd expect. Vim's mapping system is based on the characters it receives and notation like is just a nice way of specifying the code for the given character. Further, none of these represent the key being pressed vs released.īecause of this, it is difficult to make a regular key act like a modifier, difficult to make a modifier act as a regular key, and difficult to make one modifier act like another. None of these characters represent the control key itself, or the alt key itself, etc. It is up to the terminal or terminal emulator to map key presses to these characters. 96 of those are printable (alphabet, numbers, symbols, and space), and the other 32 are control characters (things like delete, bell, or end-of-transmission-block). The short of it is that, assuming an ASCII baseline encoding and ignoring all extended encodings (latin1, utf-8, etc) there are 127 characters that a terminal program can send or receive. I appologize for the length of this answer in advance. The history of terminals and characters and mappings is long (and still developing, for example 8bit meta vs utf-8 encoding). Terminal applications are different from GUI applications in that they send and receive a character stream, rather than receiving events and drawing pixels. The basis for not being able to map from the control key itself (this question) or to the control key (other similar question) is that Vim is, at its core, a terminal application. You cannot disable control without breaking (what most would consider) needed functionality.
