Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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 Aug 2 '11 at 22:33

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.

share|improve this answer
Arrr, too fast 4 me ;) Anyway, so just added a setxkbmap solution to my answer then... – rozcietrzewiacz Aug 2 '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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
This is quite handy for use in Vi/Vim – polemon Aug 2 '11 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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