I usually edit in Vim,and when pressing +, I'd rather move my hand to the right part of the keyboard where + resides rather than doing shift + =.

But when NumLock is not on, in Vim it just opens a new line above and inserts the letter k. And every time I start my PC NumLock is off.

I would like to know if there is any xmodmap trick to turn on NumLock,so I could add it to my .xinitrc.And it would be even better if I could add it to my .map file which swaps Escape and CapsLock which I load with loadkeys in my /etc/rc.local on startup.

I am using Arch Linux.


There is a package in community numlockx:

# pacman -S numlockx

and then add it to your .xinitrc:

numlockx &

There are also methods on the the Arch Wiki if you are using a login manager, such as GDM or KDM: https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup


The archlinux wiki has a page about enabling the numlock key on bootup here

  • 4
    Please never just link to an answer on StackExchange QnA sites; always include at least a summary of the solution and links for extra reference. – Caleb Jun 27 '11 at 10:06

Numlock status at startup is usually an option in the BIOS (as another option, rather than setting it per OS). Although I guess it's possible that it's already set to on, and something in Arch Linux (or other OS's) is turning it off again.

  • Any idea what that something might be? – Nils Oct 26 '11 at 20:02

This does not pretend to be the most elegant solution, but on many of my systems my users ~/.xmodmaprc file has entries that look like this:

keycode 79 = 7
keycode 80 = 8
keycode 81 = 9
keycode 83 = 4
keycode 84 = 5
keycode 85 = 6
keycode 87 = 1
keycode 88 = 2
keycode 89 = 3
keycode 90 = 0
keycode 86 = plus
keycode 82 = minus
keycode 91 = period

I use several different desktop environments on several different distros and this is a hacky but sure-fire way to make sure that no matter how the system comes down on NumLock policy, my numeric keypad gives me numbers. Basically strips the NumLock function of significance by by stripping all other values from the key-codes. You can turn NumLock on or off as you like but the only thing the keys do is spit out the number values.

  • 1
    I do something similar, but keeping the keypad keys distinct: keycode 79 = KP_7 KP_Home (i.e. Num Lock is always on), and no Num Lock key. – Gilles Jun 27 '11 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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