We have ergonomic keyboards at work which I'm not entirely used to. I seem to keep hitting the capslock key while I'm in vim
and it's starting to annoy. How can I disable this key, and or change to to be another key?

- 59,188
- 74
- 187
- 252
-
Related: Remapping caps-lock to escape, and menu to compose, on the linux console. Do you want this only in X, or in your OS (which?)'s console? – Gilles 'SO- stop being evil' Aug 02 '11 at 22:33
4 Answers
The quick and dirty way to disable it is with xmodmap
:
$ xmodmap -e 'clear Lock'
The next question is what would you like to do with it? I usually make it either a Ctrl key:
$ xmodmap -e 'keycode 66 = Control_L'
Depending on your DE/WM, there is likely a way to do this in the GUI configuration. For example Gnome has a "keyboard layout" option on the control pannels with an options tab that includes several similar layout modifications.

- 70,105
-
Arrr, too fast 4 me ;) Anyway, so just added a
setxkbmap
solution to my answer then... – rozcietrzewiacz Aug 02 '11 at 13:51
Use xmodmap
.
The setting to disable your capslock is
remove Lock = Caps_Lock
This would be placed in your .xmodmap
file.
Another option - to disable it temporarily, you can use a setxkbmap
option:
setxkbmap -option ctrl:nocaps
and then, to restore normal behavior: setxkbmap -option

- 39,269
Using xmodmap will only change the key binding while in X. If you need it on the console it's a little different. The changes below will modify X as well as the console, so I always do it this way.
For Linux add this to /etc/rc.local (or make an init script):
(echo $(dumpkeys |grep -i keymaps); echo keycode 58 = Control) | loadkeys -
For Solaris on a PC with a USB keyboard edit /usr/share/lib/keytables/type_6/reset
(for other types of keyboards you would replace type_6
with the appropriate type):
Locate this line:
key 57 all shiftkeys+capslock
Replace with this:
key 57 all shiftkeys+leftctrl up shiftkeys+leftctrl
Naturally you can replace Control with any key you would like.

- 39,666
- 4
- 75
- 104
This is a portion of my .xmodmaprc
, that turns CapsLock into Esc, and vice versa:
clear lock
keycode 9 = Caps_Lock ISO_Next_Group Caps_Lock ISO_Next_Group
keycode 66 = Escape NoSymbol Escape
add lock = Caps_Lock
You can check the keycodes by running xev
and just pressing the buttons you want to check.

- 11,431