XCompose lets one type more complex stuff as easily as one could imagine, or include fancy Emojis all around the world…


Where to find that so-called “Compose Key”

Check your OS for something called Compose key. One might find it, e.g. in Ubuntu Settings » Keyboard » Special Character Entry » Compose Key. I have it set for Right Alt (aka Alt Gr) key.

How to enable it?

On my Linux distro it was enough to simply create ~/.XCompose configuration file and include there at least the following include statement:

include "/usr/share/X11/locale/en_US.UTF-8/Compose"

Then one has to run simply:

ibus restart

And all the Compose Key shortcuts defined within the included file are already available for you. What is already available, see some examples in the following subsection:

Some of the perhaps useful shortcuts for US

Something useful in general:

  • NBSP (nonbreakable space): (Compose key, Space, Space)
  • (ellipsis): (Compose key, ., .)
  • (em dash): (Compose key, -, -, -)
  • (pilcrow sign): case-insensitive (Compose key, P, !)
  • § (section sign): case-insensitive (Compose key, o, s), (Compose key, s, o) or (Compose key, s, !)
  • ± (plus-minus sign): either (Compose key, +, -) or (Compose key, -, +)
  • (euro currency symbol): either (Compose key, =, e) or (Compose key, e, =)
  • £ (pound currency symbol): either case-insensitive (Compose key, -, l) or (Compose key, l, -)
  • © (copyright): either (Compose key, o, c), (Compose key, O, C), or (Compose key, C, O)

Some special German characters and ligatures:

  • ä (a with diaeresis): either (Compose key, ", a) or (Compose key, a, ")
  • ö (o with diaeresis): either (Compose key, ", o) or (Compose key, o, ")
  • ß (small sharp s): (Compose key, s, s)
  • (capital sharp s): (Compose key, S, S)

Other special punctuation:

  • ¿ (inverted question mark): (Compose key, ?, ?)
  • ¡ (inverted exclamation mark): (Compose key, !, !)

Arrows:

  • (leftwards arrow): (Compose key, <, -)
  • (rightwards arrow): (Compose key, -, >)
  • (upwards arrow): either (Compose key, |, ^) or (Compose key, ^, |)
  • (downwards arrow): either (Compose key, |, v) or (Compose key, v, |)
  • (leftwards double arrow): (Compose key, =, <)
  • (rightwards double arrow): (Compose key, =, >)
  • (upwards double arrow): (Compose key, =, ^)
  • (downwards double arrow): (Compose key, =, v)

Fractions:

  • ½ (one half): (Compose key, 1, 2)
  • (one third): (Compose key, 1, 3)
  • ¼ (one fourth): (Compose key, 1, 4)
  • ¾ (three fourths): (Compose key, 3, 4)

Even some emojis:

  • (heart): (Compose key, <, 3)
  • 🖖 (long live): (Compose key, L, L, A, P)
  • 💩 (pile of poo): (Compose key, p, o, o)

How to define some custom hotkeys?

Edit your ~/.XCompose configuration file by some lines similar to the following example:

include "/usr/share/X11/locale/en_US.UTF-8/Compose"

<Multi_key>     <f>     <r>     : "FREYAR-"
<Multi_key>     <n>     <n>     : "N/A"
<Multi_key>     <p>     <i>     : "𝛑"
<Multi_key>     <m>     <u>     : "μ"
<Multi_key>     <l>     <m> <b> : "λ"
<Multi_key>     <s>     <u> <m> : "Σ"
<Multi_key>     <i>     <n> <f> : "∞"
<Multi_key>     <equal> <equal> : "≡"
<Multi_key>     <a>     <l> <l> : "∀"
<Multi_key>     <plus>  <1>     : "👍"
<Multi_key>     <minus> <1>     : "👎"
<Multi_key>     <o>     <k>     : "✅"
<Multi_key>     <n>     <o> <k> : "❌"
<Multi_key>     <p>     <o> <i> : "⌘"

A sequence of keys Compose Key (e.g. Alt Gr in my case), f, and r, which will insert FREAYR text. I had to write that word a lot and I tend to make there a typos, but since I used to this Compose Key shortcut, my life was a bit easier…

Similar custom rule is on each line of the given example. I sometimes would like to write Σ (meaning sum), μ (meaning “micro”), λ (meaning Greek letter lambda used e.g. in Functional Paradigm), ∞ (meaning infinity), ≡ (meaning infinity), and so on. Define as many shortcuts as you want.

Syntax of XCompose file

Each non-empty line defines exactly one shortcut. Each shortcut definition consists of three parts:

  • sequence of “key codes” (input/encoding sequence),
  • colon : as a separator
  • and the output text delimiter by double quotes ".

Compose Key is represented by <Multi_key>.

As one can see letters are case-sensitive and they are denoted simply as <a> or <A>. Each key representing more complex character has to be written by a word. Here is listed a few of those:

key placeholder
` ` <space>
+ <plus>
- <minus>
= <equal>
( <parenleft>
) <parenright>
[ <bracketleft>
] <bracketright>
{ <braceleft>
} <braceright>
, <comma>
; <semicolon>
: <colon>
. <period>
? <question>
! <exclam>
' <apostrophe>
" <quotedbl>
< <less>
> <greater>
^ <asciicircum>
* <asterisk>
% <percent>
/ <slash>
\ <backslash>
_ <underscore>
| <bar>
# <numbersign>
~ <asciitilde>
& <ampersand>
$ <dollar>

<
Blog Archive
Archive of all previous blog posts
>
Next Post
Go v1.24