I'm new to vi. Actually I'm using it just to modify small text files. I've a serious and unusual, I think, problem with the numeric keypad, as follow: I write vi IN and press enter. This make me access to the file named IN. Then I use arrow keys (or hjkl) to move the cursor through the file. Then I press i to activate the insert mode and write. Here comes the problem: numeric keypad doesn't work properly, since I get pqrstuvwxyl when I press 0123456789+ (,.-*/= still work).

  • 1
    Why was my question migrated here? The problem was not about the Mac but about Vi. In fact, as I said, the numeric keypad was not working just in Vi. On the contrary it has always worked in the terminal or in other applications.
    – Enlico
    Commented Feb 19, 2016 at 20:06

2 Answers 2


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

  • Maybe I didn't get the point in what you wrote. When I'm in the terminal, the keypad works well (inserts numbers). The "strange" behavior was happening only in the insert mode of Vi.
    – Enlico
    Commented Feb 20, 2016 at 17:50
  • 1
    The mode switch is only active in the program that requested it (in this case: vi). So the keypad works normal in other programs including the shell. I've added this clarification to the answer. Commented Feb 20, 2016 at 21:09

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.

  • The edit is misleading. It's false that "I don't recall enabling this"; on the contrary I am sure I never enabled it in this window!
    – Enlico
    Commented Feb 19, 2016 at 20:09
  • Furthermore, there was a part in which I asked for someone to tell me why this option had that consequence, if there are other consequences, and if it is possible that I enabled it by a typo's side effect.
    – Enlico
    Commented Feb 19, 2016 at 20:15
  • AFAIK the option is enabled by default (at least it's enabled on my Mac as well and I'm quite sure I didn't deliberately enable it myself). As for your second comment: see the remark in the edit history regarding follow-up questions hidden in answers.
    – nohillside
    Commented Feb 20, 2016 at 16:31
  • 1
    The reference is that I always used numeric keypad to insert numbers in Vi. Anyway, maybe the the option could have been activated by the upgrade from Yosemite to El Capitan (still I'm sure I used the numeric keypad to insert the numbers after the upgrade).
    – Enlico
    Commented Feb 20, 2016 at 17:47
  • 1
    It used to be on by default. Starting in OS X 10.11 El Capitan it is off by default. Vim is enabling Application Keypad Mode (DECKPAM) without providing any default mappings. I have not been able to discover why Vim does this. I think it should either supply default mappings or not enable DECKPAM by default.
    – Chris Page
    Commented Apr 27, 2016 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .