3

In several terminal programs, such as PuTTY, SecureCRT, iTerm, and Mac OS Terminal, if I have NumLock on and I press the number pad (numpad) keys 0123456789 in insert mode, my vim looks like this:

y                                                                                                          
x
w
v
u
t
s
r
q
p

~

If I use the numpad on the command line, it enters the numbers I expect.

How do I make vim type the right characters from the numpad?

4

Short answer

Turn off “application keypad mode switching.”

Terminal-specific instructions

  • PuTTY (also here): Terminal > Features > uncheck Disable application keypad mode
  • SecureCRT: Session Options > Terminal > Emulation > Modes > Mode switching > uncheck Enable keypad mode switching
  • iTerm: Switch to iTerm2 or see general instructions below.
  • iTerm2 (also here): Preferences > Profiles > Keys > Load Preset… > xterm with Numeric Keypad or add the settings manually as shown here.
  • Mac OS Terminal (also here): Preferences > Profiles > Advanced > uncheck Allow VT100 application keypad mode
  • Other: look for an option like application keypad mode or see below.

General instructions for .vimrc

If the terminal-specific instructions don't work for you, you can fix it in vim by adding the following mappings to your .vimrc:

: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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.