I want to swap the Caps Lock and Escape key as specified in this answer:
Use the keyboard preferences to swap Caps Lock and Escape - seriously, how often do you use Caps Lock? Using vim you will be using Escape all the time, and having it available on the home row makes a huge difference. With the standard Ubuntu desktop, go through the menus: System -> Preferences -> Keyboard -> Layouts tab. Then hit the "Layout Options" button, click on the triangle next to "Caps Lock key behaviour" and select "Swap ESC and CapsLock".
but, I'm using Ubuntu Server with no gui, so how would I do this from the command line?
Swapping Esc and CapsLock, with combinations, e.g. Ctrl-Esc
dumpkeys | grep -P -i "^keymaps.*|^keycode.*escape|^keycode.*lock" > swap.map
1
and58
, while deleting the other_Lock
lines; leave the first line intact though.sudo loadkeys swap.map
/etc/rc.local
, before theexit 0
line, to activate the swap upon boot:See the source for a more general explanation.