Swap esc and caps lock on Ubuntu 11.10


  • caps lock is not very useful
  • caps lock changes the keyboard state, which might be undesirable if you want to use in a keyboard macro program such as Autokey which cannot stop Caps lock from changing state
  • the venerable VIM extensively uses Esc to change modes, so you would rather have it closeby


Append some code to your ~/.Xmodmap file. It’s executed at the right time at startup by the xmodmap command, so that your modifications take place every time.

echo "
! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock" >> ~/.Xmodmap