MacOS – how to use the + on the numeric keypad for “+p in vim, Mac Os X

keyboardmacbook promacosvi

Under Mac OS X, in vim, when I issue the command "+p using the numeric keypad for the + in normal mode, instead of pasting stuff from the system clipboard Vim enters insert mode and inserts the letters kp.

The same kind of thing happens to me under Linux when I have the Numlock off, however, my Apple Keyboard (usb keyboard) does not have a Numlock key, instead it has a Clear key.

Does anyone have any ideas of how to get around this and so that I can use the keypad for entering the + in +p"?

Best Answer

It’s Vim, feel free to remap anything to anything you want.

To detect what you numpad + sends to Vim press C-v then + on numpad – you will see something like

^[Ok

^[ is escape, so you may command your Vim

:map "<esc>Ok "+

Now it should work as expected by you.

However, it would be better to do this kind of mappings not in Vim but in your terminal emulator (which you have not mentioned) by two reasons:

  • In Vim you have to map all possible prefixes explicitly. You can perform :map <esc>Ok + but it won’t affect "<esc>Ok.
  • Mapping <esc>Ok to something will add a delay in processing single <esc> press (see :h timeoutlen).