Posted almost 9 years ago. Visible to the public. Linked content.

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

Although you can access many symbols using the AltGr key you may be missing some, like the en-dash (–) or em-dash (—). You can use a compose key 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 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.
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.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Arne Hartherz
Last edit:
over 2 years ago
by Florian Heinle
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more