Apple - Numeric keypad keys in vi insert letters instead of numbers

I solved the problem on my own, but I'd like to know WHY my solution works. I deselected the option the red arrow indicates in the following picture enter This is italian, but the english version of the same window is here

But I don't recall enabling this but there it is.


As far as I understand, there are two possible modes for number keypads of VT100 terminals: the normal Numeric keypad mode and the Application keypad mode. The latter has the keypad keys send not numbers, but escape sequences. E.g., the '1' key sends <ESC>[Oq, the '2' key sends <ESC>[Or, of which only the letters q and r are visible on the screen. These are control sequences that the program (host) may interpret as commands for some features. So, in this mode, the keypad keys are practically used as additional function keys.

In accordance with the VT100 terminal standard, a program (host) may 'ask' the terminal to switch the keypad to application mode. (It can do this by sending a specific control sequence to the terminal.) Vi and Vim are known to do this. The mode switch is not universal, but on a program to program base: it's only active in the program that requested it. In other programs, including the shell, the keypad remains in Number mode. The default setting in OS X's Terminal.app is to allow programs to switch to Application mode, which is what you now disabled by un-checking the option "Allow VT100 application keypad mode". (BTW: In OS X 10.7 this option is labelled "Strict VT100 keypad behaviour".)

See also:

http://www.vt100.net/docs/vt100-ug/chapter3.html https://ttssh2.osdn.jp/manual/en/usage/tips/appkeypad.html

Tags:

Macos

Vi

Terminal