Control-capital-u means Unicode, and code point (a four-digit hexadecimanl number, though leading zeros are optional with some versions) for em dash (or any other Unicode character) can be found via the Character Map in Ubuntu (gucharmap).
The first option allows you to separately type the correct digits for your character, which appears upon hitting Enter or Space. You can also edit the numbers you typed using backspace before pressing Enter.
Many of the answers above are either specific to the em dash, require memorizing alt codes, or are better suited for one-off uses. The following works for any unicode character without alt codes. It uses Autokey, a handy text substitution utility.
I have it set up such that I type the name of a character, prepended with a slash, and Autokey converts it for me. For example:
Full instructions with pictures here. Summary below. (Also, similar methods here)
# Edit (April 2018). Autokey now uses python 3 by default. So try
pip3 install autokey
# Original instructions.
# Install the original autokey
sudo apt-get install autokey-gtk
# Update autokey to python 3 using pip3
pip3 install --user autokey-py3
Run the program. For me it installed to ~/.local/bin/autokey-gtk
I prefer remapping one of my lesser-used keys to an em-dash so that I don't have to type a crazy combination of keys in order to get it.
Identify a key you don't mind remapping. My laptop has a second backslash key, so I used that.
Find the keycode for that key using xev. Run xev from a terminal, and press the key, paying attention to the keycode that pops up. When I press my key, for instance, I get state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,, so I know my keycode is 94.
Assign the emdash to that keycode using xmodmap. I run xmodmap -e "keycode 94 = emdash ellipsis" because I also want to assign Shift+backspace to the ellipsis character.
Figure out a way to get xmodmap to run on startup. This is the part I'm unsure about. I think it involves editing ~/.Xmodmap, but there's some debate about this, apparently.
The following keyboard layouts contain the em dash:
$ sgrep -o '%r\n' '"\"" _quote_ "\"" in ("name[Group1]" .. "\n" in outer("{" .. "}" containing "emdash"))' /usr/share/X11/xkb/symbols/??
Azerbaijan
Bulgaria
Bulgaria - Traditional phonetic
Switzerland - German (Macintosh)
Germany
Germany - Neo 2
Finland
France - Bepo, ergonomic, Dvorak way
France - Macintosh
Ireland
Iceland - Macintosh
Iceland - Dvorak
Latvia
Mongolia
Norway
Norway - Northern Saami
Ukraine
USA - Macintosh
USA - Colemak
Personally, I use Colemak, in which the em dash is AltGr+Shift+-.
To get xmodmap to run on startup in Ubuntu 12.10, Go to Dash Home. Type in Startup. Click on Startup Applications. Click Add. In the "add startup program" window, give it a name. In the command box, enter: xmodmap -e "keycode 94 = emdash ellipsis"
Then, click on Add. You'll see the program name you just gave this under startup applications. Close the windows. The command will run the next time you start the computer. (I just spent a week and many hours reading these posts here and finally figured it out on my own.) This might not be the best way to do this, but it works.
or
Control-capital-u means Unicode, and code point (a four-digit hexadecimanl number, though leading zeros are optional with some versions) for em dash (or any other Unicode character) can be found via the Character Map in Ubuntu (
gucharmap
).The first option allows you to separately type the correct digits for your character, which appears upon hitting Enter or Space. You can also edit the numbers you typed using backspace before pressing Enter.
If this shortcut doesn't work check if your input method is iBus.
I could not find a way to type it using AltGr and default settings, but I found another way:
Go to System -> Preferences -> Keyboard.
Select the Layouts tab.
Click Options.
Under Compose Key Position (drop-down), choose a key to use for composing — I chose the Right Win (right Windows key).
Now press and release the compose key, then type
---
to get the em-dash.[Here's a list of more characters you can type this way.]
UPDATE: As of Ubuntu 12.04
Go to System Settings > Keyboard.
Under Typing tab, select Layout Settings link (at the bottom of the dialog box).
Click Options.
Under Compose key position (drop-down), choose a key to use for composing — I chose the Right Win (right Windows key).
Now press and release the compose key, then type
---
to get the em-dash.Go Character Map app (
gucharmap
, on Applications → Accessories).Click Search → Find
Type 'em dash' and click 'Find Next'
Double-click the symbol, which will put it in the 'Text to Copy' box at the bottom.
You can then copy-and-paste it where you want it.
I believe this is the best way to have some special chars, but I don't know if it works with all keyboards.
In my Brazilian ABNT2 keyboard I can get it with the Compose key more tree hyphens. The compose key is mapped to my right Ctrl key, so:
To get the en dash, use Ctrl --. (hyphen, hyphen, dot)
A bonus one, for the … type:
You can configure your Compose key in: settings → keyboard → shortcuts → typing.
Autokey
A generalised method for any unicode character
Many of the answers above are either specific to the em dash, require memorizing alt codes, or are better suited for one-off uses. The following works for any unicode character without alt codes. It uses Autokey, a handy text substitution utility.
I have it set up such that I type the name of a character, prepended with a slash, and Autokey converts it for me. For example:
Full instructions with pictures here. Summary below. (Also, similar methods here)
Install the python-3 version of Autokey, which plays nicely with Unicode.
Run the program. For me it installed to
~/.local/bin/autokey-gtk
Add a "New Phrase"
Add the desired character in the main text box
Add an abbreviation
Profit
I prefer remapping one of my lesser-used keys to an em-dash so that I don't have to type a crazy combination of keys in order to get it.
xev
. Runxev
from a terminal, and press the key, paying attention to the keycode that pops up. When I press my key, for instance, I getstate 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
, so I know my keycode is 94.xmodmap
. I runxmodmap -e "keycode 94 = emdash ellipsis"
because I also want to assign Shift+backspace to the ellipsis character.~/.Xmodmap
, but there's some debate about this, apparently.The following keyboard layouts contain the em dash:
Personally, I use Colemak, in which the em dash is AltGr+Shift+-.
Ubuntu 14.04, 15.04, & 15.10
Note: this method has been referenced previously but it has changed in 14.04 and the link to the compose key character reference is now broken.
The settings dialog to set the compose key has moved in 14.04.
Now all you have to do to is press and release the
Compose Key
and then type your sequence (e.g.---
for emdash) and it will be converted. :)New link for compose key character reference
To get xmodmap to run on startup in Ubuntu 12.10, Go to Dash Home. Type in Startup. Click on Startup Applications. Click Add. In the "add startup program" window, give it a name. In the command box, enter: xmodmap -e "keycode 94 = emdash ellipsis"
Then, click on Add. You'll see the program name you just gave this under startup applications. Close the windows. The command will run the next time you start the computer. (I just spent a week and many hours reading these posts here and finally figured it out on my own.) This might not be the best way to do this, but it works.