06.06.2019
The German keyboard layout is just terrible for programming:
Picture from Wikipedia.
Imagine using [square brackets] or even {curly brackets} often. Who thought it was a good idea to separate them in addition to mapping them to right alt
and the number line?!
However, I have to write texts in German occasionally and using ae, ue and oe instead of ä, ü and ö looks unprofessional. Switching the keyboard layout is also not really /comfy/ because it only adds confusion.
Fortunately, the compose key exists exactly for such problems. It doesn’t just help typing German special characters, but any special character: The list of default sequences is 6143 lines long!
You can even define your own rules to create a compose sequence for any Unicode character you want.
Using the compose key is really simple:
Depending on the sequence, a special character is inserted.
To make typing /comfy/ again, simply add this one line to your .xinitrc
:
setxkbmap -option compose:ralt
This sets the right alt
key as compose key, to see other options try
grep "compose:" /usr/share/X11/xkb/rules/base.lst
.
Hint: setxkbmap
needs a display to work, so you have to execute it after you start your xserver.
Hint: You can also play around with the setxkbmap
command, it allows you to do other useful things as well. I have my capslock
remapped to Esc
for example.
Most compose sequences are quite graphical:
oc
translates to ©
"a
translates to ä
, same with ö
and ü
~n
translates to ñ
ss
translates to ß
; in German, ss is a common substitution for ß14
translates to ¼
, same with other fractions^2
translates to ²
, same with other numbers_1
translates to ₁
, same with other numbers/O
translates to Ø
=C
translates to €
All the default sequences can be found here:
/usr/share/X11/locale/en_US.UTF8/Compose
.
To create your own compose sequences, copy the defaults file to ~/.XCompose
. Alternatively, create an empty file and include the defaults with include "%L"
.
In this file, you can add your own sequences using this format:
<Multi_key> <g> <a> : "α"
As always, it’s a good idea to check out the man page:
man Compose
If you want to give me some feedback or share your opinion, please contact me via email.
© Niklas Bühler, 2021 RSS / Contact me