Insert an ndash and other special characters using the Compose key on Linux

Updated . Posted . Visible to the public.

Although you can access many symbols using the AltGr key Show archive.org snapshot you may be missing some, like the en-dash (–) or em-dash (—). You can use a compose key Show archive.org snapshot for them instead.

First, make sure you have a compose key configured.

Configuring a compose key

I suggest using the "Menu" key which is located between the right Meta Show archive.org snapshot and Ctrl key.

Ubuntu / MATE

Control Center → Keyboard → Layout → Options → Position of Compose Key

Ubuntu / Gnome

On Gnome 2: System → Preferences → Keyboard → Layouts → Options → Compose key.
On Gnome 3: Settings → Keyboard → Shortcuts → Typing → Compose Key.
If you have Tweaks installed: Open Tweaks -> Keyboard & Mouse -> Next to "Compose Key" click on "Disabled" (yes, this actually is a Button, who designed this?)

Xubuntu / Xfce / Any window manager

Xfce does not offer a settings screen for this, but you can use this command ("menu" is the context menu key; other people may prefer "lwin" or "rwin" instead):

setxkbmap -option compose:menu

Add that command the list of started applications on Xfce to set it every time your window manager is started (in Settings manager / Session and Startup / Application Autostart / Add).

Using the compose key

To insert special characters press (and release) your compose key, then input a combination. For example use "--." to create an en-dash or "  " (2 spaces) for a non-breaking space (aka nbsp). Check the link below for a list of valid compose combinations.

Note that this works across all programs -- unlike the Ctrl+Shift shortcut which works only on Gnome applications.

List of compose keys

For the full list of compose keys see /usr/share/X11/locale/<locale>/Compose. All entries starting with <Multi_key> are compose keys.

Setting up 3rd level shift key

Although the compose key works just fine for umlauts, it might break your typing flow if you're touch typing. You could add another level of keyboard shortcuts that allows you to quickly type e.g. umlauts via AltGr+o. You could do that via Xmodmap (if you want to do it this way, you'll already know how) or follow these instructions to modify the us symbol table: Umlaute auf der englischen Tastatur tippen Show archive.org snapshot .

Arne Hartherz
Last edit
Jonas Schiele
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2011-03-02 10:20)