How do I get the numpad to work in vim using iterm2 on osx with term=xterm?

13,899

Solution 1

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

Solution 2

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

Solution 3

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

Solution 4

but it removes some colors in my vim.

if you just need it some times, just type:

:set term=ansi

in VIM

Best regards

Share:
13,899

Related videos on Youtube

J0hnG4lt
Author by

J0hnG4lt

Updated on September 18, 2022

Comments

  • J0hnG4lt
    J0hnG4lt over 1 year

    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

  • gitaarik
    gitaarik almost 9 years
    I didn't have this preset, so in my answer I explained how you can add these shortcuts yourself.
  • scarver2
    scarver2 over 8 years
    It appears that the preset no longer exists in iTerm 2.1.1
  • scarver2
    scarver2 over 8 years
    For the Enter key, choose the Send Hex Codes action and enter 0x0D.
  • J0hnG4lt
    J0hnG4lt over 8 years
    Recently did a new OS install. The preset is still there in iTerm 2.1.1.
  • crazyGuy
    crazyGuy over 8 years
    This solution works only on the native terminal, but not with iTerm
  • ecmanaut
    ecmanaut about 8 years
    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.)
  • KLaw
    KLaw about 8 years
    Works for me. I'm using iTerm2 Build 2.1.4.
  • J0hnG4lt
    J0hnG4lt about 5 years
    Latest beta, preset's gone (again?).