Insert symbols with the compose key
Unicode is great. It contains all the imaginable symbols from all the worlds languages. Even mathematical operators and icons.
Your keyboard layout probably contains all the symbols you need to write in your language. If you need to write in two languages, switchind between their respective layouts is manageable. Provided they both use the same layout for basic letters just your numbers and symbols get mixed up. But what if they don’t?
Default for Czech is QWERTZ, for French AZERTY. This leads to a lot of pain.
Maybe you, like me, prefer to use the standard US layout and need to type some special or accented character only occasionaly. You can keep switching layouts if you have them set up. Or you can look up the symbol online and copy-paste it. You can insert the symbol using it’s Unicode code.
All of these ways have their problems.1 The layouts trouble I mentioned above. Looking up and copying the symbol is slow and cumbersome. Inserting by code means you need to memorize the codes otherwise you end up looking up the symbol anyway.
Truth be told, I really don’t see the point in memorizing unicode codes.2
Isn’t there was a better way?
A simpler, more memorizable way?
Turns out there is! And it has been here for a long time.
The Compose key, or ⎄.
What the ⎄ 🔗
The compose key was introduced in 1983 by DEC on the LK201 keyboard for the VT220 terminal.
On the Sun 5 keyboards the compose key was placed on the right end of the bottom row. Kind of in the area where the right Alt, Super and Ctrl are on modern keyboards.
Eventually, because of lack of support in Windows and Mac OS the compose key disappeared from modern keyboards.3
Setting up compose key in Gnome 🔗
Setting up compose key in Gnome is actually quite easy.
- Open GNOME Tweaks and navigate to the Keyboard & mouse section.
- Open Compose key settings (just under Emacs-input toggle).
- Bind the Compose key. The dialog offers multiple keys to map, right Super or Menu would be a good choice.
I set it up as right Alt as my laptop keyboard does not have right Super.
Using it! 🔗
So, how does it work? You press and release the compose key you bound earlier, then press and release two or more keys and it will input the corresponding symbol.
A few examples:
⎄ = E ⇒ €
⎄ c | ⇒ ¢
⎄ S | ⇒ … yeah no. turns out the
$ is already present on a keyboard.
But you can do fractions ⎄ 2 3 ⇒ ⅔, greek letters ⎄ / u ⇒ µ, accented letters ⎄ c c ⇒ č, typographic symbols and much more. So, how do you learn the combinations?
Of course not by trying all the possible combinations.
The relevant file is usually located at
wc -l /usr/share/X11/locale/en_US.UTF-8/Compose
Defining custom sequences 🔗
If you want, you can define your own sequences as well.
First, copy the Compose file corresponding to your locale to your home directory as
cp /usr/share/X11/locale/en_US.UTF-8/Compose ~/.XCompose
Let’s add a line for the compose key symbol:
<Multi_key> <D> <O> : "⎄" U2384
And now you can easily type ⎄ as ⎄ D O!
Now you can insert special symbols in an easy mnemonic way without the need to switch layouts or look up their codes and it works everywhere on your system!
I myself only learned about compose key recently and could’t beleive I didn’t find out about it much earlier. Well, hopefully you learned something new as well!
There are more ways of inserting symbols than I listed, but I never really used them. There is actually a third and fourth level on a keyboard accessed by AltGr and AltGr + Shift which give you some extra symbols and accents. ↩︎
You might need to memorize codes that are not covered by the compose functionality. Or add them yourself. ↩︎