The compose key

Home / RSS / Contact me


The German keyboard layout is just terrible for programming:

QWERTZ layout 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.

How it works

Using the compose key is really simple:

  1. Tap the compose key
  2. Type a sequence of characters

Depending on the sequence, a special character is inserted.

Quick setup

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.

Some helpful sequences

Most compose sequences are quite graphical:

All the default sequences can be found here:

Define your own

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> : "α"

More information

As always, it’s a good idea to check out the man page:
man Compose

Want to leave a comment?

If you want to give me some feedback or share your opinion, please contact me via email.

© Niklas Bühler, 2020 RSS / Contact me