Strange behavior of the numpad in the Vi editor if using the RXVT virtual terminal

I recently changed my default terminal to rxvt. It spawns really fast, can be run in server-client mode and is higly configurable. I think it might be the best terminal currently around.
But I experienced strange behavior of the numpad while running the Vi editor.
And this is how it can be fixed. Please note that i map only the numbers and not the arrow keys, because I use the Neo keyboard layout, where great arrow keys are available on Level 4.

1. Create/open a file in your home directory called .Xmodmap:

vim .Xmodmap

and add the following lines:

keycode 63 = KP_Multiply
keycode 79 = KP_7
keycode 80 = KP_8
keycode 81 = KP_9
keycode 82 = KP_Subtract
keycode 83 = KP_4
keycode 84 = KP_5
keycode 85 = KP_6
keycode 86 = KP_Add
keycode 87 = KP_1
keycode 88 = KP_2
keycode 89 = KP_3
keycode 90 = KP_0
keycode 91 = KP_Decimal
keycode 112 = Prior
keycode 117 = Next

2. Create/open a file in your home directory called /.xinitrc:
vim ~/.xinitrc
and add the following lines:
xmodmap ~/.Xmodmap

3. Open your .zshrc or .bashrc depending on the shell you use:

vim .zshrc

and add the following line:

export TERM=ansi

And you’re done! Note that you might need to restart the terminal.

One Reply to “Strange behavior of the numpad in the Vi editor if using the RXVT virtual terminal”

  1. I found this in a forum:

    A cleaner solution to this problem would probably be editing your ~/.Xdefaults for urxvt instead of changing the keymap for the whole system.

    In order to get the numpad working in my zsh+urxvt+vim setup I had to add these lines:

    URxvt.keysym.KP_Add: +
    URxvt.keysym.KP_Subtract: –
    URxvt.keysym.KP_Multiply: *
    URxvt.keysym.KP_Divide : /
    URxvt.keysym.KP_Decimal : .
    URxvt.keysym.KP_Separator : ,
    URxvt.keysym.KP_1: 1
    URxvt.keysym.KP_2: 2
    URxvt.keysym.KP_3: 3
    URxvt.keysym.KP_4: 4
    URxvt.keysym.KP_5: 5
    URxvt.keysym.KP_6: 6
    URxvt.keysym.KP_7: 7
    URxvt.keysym.KP_8: 8
    URxvt.keysym.KP_9: 9
    URxvt.keysym.KP_0: 0

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.