In my current machine, I use Vim 8.1 in a Ubuntu 18's default terminal (Vim is running with TERM=xterm256-color, which is a requirement for me). Everything works perfectly, with the exception of the fact that the keyboard's Numpad numerical keys do not work Vim's Normal Mode (as a test, I see that they do work in GVim). For instance, it does not matter what mappings I try to use them in, nothing happens. But if I open GVim and try there, they work perfectly.

I have found multiple questions in multiple Stackexchange sites and also eslewhere, but they all talk about very particular cases. For instance, this one has seemingly good solutions for Mac OS users of Vim with TERM=xterm, while this one teaches how to solve this problem in case it appears when using Ubuntu in a virtual machine. This one teaches how to solve the problem when using Vim in SecureCRT terminals. Many describe how to solve the problem for PuTTy (e.g. this Vim Wiki). Also, it is easy to find online many suggestions of crazy keybindings that are supposed to solve the problem.

None of those worked for me. What is more surprising, I see no mention anywhere about how one would solve this problem when using Vim Ubuntu's default terminal (with Vim's TERM=xTerm256-color).

Hence me asking for help on that task. How could I try solving this issue?

EDIT: One example that might be informative is the following. Suppose that I include in my .vimrc:

set showcmd
nnoremap <k4> :echom "4-left"<CR>
nnoremap <k8> :echom "8-up"<CR>
nnoremap <k6> :echom "6-right"<CR>
nnoremap <k2> :echom "2-down"<CR>

Then, suppose that I start GVim and hit the Numpad keys 4, 8, 8 and 6, in that order. In the left of the bottom bar I will see "4-left", "8-up", "8-up" and 6-right" (i.e. mappings worked), in that order and in the right of the bottom bar I will see 4, 8, 8 and then 6 appearing, in that order.

Now, suppose that I open Vim and again hit the Numpad keys 4, 8, 8 and 6, in that order. Nothing shows up in the left of the bottom bar (no command is issued) and in the right of the bottom bar the number 4886 appears.

  • Well, first, what terminal are you actually using and are you sure configuring it as xterm-256color is actually correct? Commented Jan 9, 2019 at 6:37
  • @ChristianBrabandt I am using GNOME Terminal 3.28.2. I tried setting term=xterm-256color' as per https://askubuntu.com/questions/67/how-do-i-enable-full-color-support-in-vim, but same happens with term=gnome-256color` and, in fact, with anything that I set term to. Commented Jan 9, 2019 at 8:17
  • Could you provide examples of the maps that work in gVim, but do not in terminal Vim?
    – Ralf
    Commented Jan 9, 2019 at 9:00
  • @Ralf I have tried many. Take for instance: nnoremap <k4> :echom "4-left"<CR>, nnoremap <k8> :echom "8-up"<CR>, nnoremap <k6> :echom "6-right"<CR>, nnoremap <k2> :echom "2-down"<CR>. Commented Jan 9, 2019 at 9:14
  • @Ralf I edited the question with what I think might be an illustrative example using those mappings. Commented Jan 9, 2019 at 9:23

1 Answer 1


I think that GNOME-Terminal does not distinguish between a numpad key and the corresponding "normal" key.

Just open a terminal and switch the numpad off, so that numbers are disabled, but Numpad-Home etc are active.

Then press Ctrl-V followed by Numpad-HOME. This will output ^[[H. Now press Ctrl-V followed by HOME. This will also output ^[[H. So GNOME-Terminal emits the same codes for the key on the numpad and the corresponding "normal key".

Maybe the center key (5) is different, as I don't know the corresponding "normal key".

This seems also be true for Ctrl-Keys (Ctrl-HOME and Ctrl-Numpad-HOME both result in ^[[1;5H).

I don't know if there is any setting, so GNOME-Terminal sends different codes for the numpad keys.

PS: I also tested with XTerm, same result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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