9

I am working from an iMac running Yosemite and using this keyboard. The number pad works in the terminal, but when I open vim or less it does not.

For example using less, if I type for the number 8, I get ESCOx, not an 8. In vim 7.2 (in command mode), it inserts an x. How do I fix this behavior? I got this keyboard specifically for the number pad.

  • As far as I know, that's a special "feature" of vim. It also happens on Linux too. – nfechner Aug 21 '15 at 13:34
  • can anybody explay what are the features that are supposed to be enabled? I am curious about what would be a scenario where I would want this to be enabled – santiago arizti Sep 11 '18 at 15:36
19

If you are using Terminal (not iTerm or others), there is a setting that might help. Turn off this setting (sorry, it's in german. But the location should be the same):

Sorry for the german screenshot

If you are using iTerm, there is at least a fix for vim: You can remap the keys to get this to work. Just add the following lines to your ~/.vimrc (Create it, if it doesn't exist.)

inoremap <Esc>Oq 1
inoremap <Esc>Or 2
inoremap <Esc>Os 3
inoremap <Esc>Ot 4
inoremap <Esc>Ou 5
inoremap <Esc>Ov 6
inoremap <Esc>Ow 7
inoremap <Esc>Ox 8
inoremap <Esc>Oy 9
inoremap <Esc>Op 0
inoremap <Esc>On .
inoremap <Esc>OQ /
inoremap <Esc>OR *
inoremap <Esc>Ol +
inoremap <Esc>OS -
inoremap <Esc>OM <Enter>

Source: a comment in the vim wiki.

  • This definitely solves the pain. Evidently this is also answered here – irritable_phd_syndrom Aug 21 '15 at 14:11
  • Glad it helped.. – nfechner Aug 21 '15 at 14:14
  • Something new in Terminal Preferences (Terminal 2.7.3, Sierra) next to that checkbox is a message indicating that Num Lock (which is mapped from Keypad Clear by default) can be used to enter digits while application mode is active. – NReilingh Jul 31 '17 at 17:48
1

If you're using iTerm and I correctly understood your question, in iTerm2 there is an appropriate preference:

http://www.twistermc.com/39930/use-number-pad-vim-iterm2/

You must log in to answer this question.

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