52

My numpad works in iterm2 (bash), but it inserts characters instead of numbers in insert mode for vim.

How can I get vim to recognise the correct escape codes.

I have tried editing the escape codes as suggested here without any luck: http://code.google.com/p/iterm2/issues/detail?id=702

4 Answers 4

86

Looks like the answer is to go into Preferences->Profiles->Keys and load preset of: "xterm with Numeric Keypad".

6
  • 1
    I didn't have this preset, so in my answer I explained how you can add these shortcuts yourself.
    – gitaarik
    Jul 13, 2015 at 9:05
  • It appears that the preset no longer exists in iTerm 2.1.1
    – scarver2
    Aug 14, 2015 at 17:28
  • 1
    Recently did a new OS install. The preset is still there in iTerm 2.1.1.
    – J0hnG4lt
    Oct 2, 2015 at 16:10
  • 3
    Works in iTerm 2.1.4 too, though I also had to add a new shortcut to insert hex key code 0xd for NumPad's Enter key to work. (Weirdly not detected as the Num-⏎ key already registered, but as ⏎ on its own, when set up.)
    – ecmanaut
    Feb 23, 2016 at 19:34
  • 1
    Works for me. I'm using iTerm2 Build 2.1.4.
    – KLaw
    Apr 20, 2016 at 15:48
22

For me the solution was disabling VT100 Application Keypad-Mode in Preferences > Profiles > Advanced.

1
  • 4
    This solution works only on the native terminal, but not with iTerm
    – crazyGuy
    Dec 16, 2015 at 9:36
14

You can add global keyboard shortcuts in Preferences -> Keys and map the numpad characters to "Send Text" actions to send the text they are supposed to send.

iTerm2 keys preferences

1
  • 8
    For the Enter key, choose the Send Hex Codes action and enter 0x0D.
    – scarver2
    Aug 14, 2015 at 17:34
8

but it removes some colors in my vim.

if you just need it some times, just type:

:set term=ansi

in VIM

Best regards

You must log in to answer this question.

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