170

The title pretty much says it all: how can I type Unicode characters - specifically the em-dash —?

muru
  • 197,895
  • 55
  • 485
  • 740
  • Not a general solution, but indeed the em-dash can be had with altGr+- (under Ubuntu-MATE at least, for a couple of years now). There are quite a few more around altGr+something (ellipsis, fractions, multiply-×,...) – Frank N Dec 09 '19 at 14:38

9 Answers9

186
  • Ctrl+Shift+U, then 2 0 1 4 and Enter

or

  • Ctrl+Shift+U+2014

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.

pbhj
  • 3,231
sladen
  • 6,424
  • 7
    Works for me. Didn't need to press enter though, the — appears as soon as i release ctrl and shift. – Alistair Buxton Mar 21 '11 at 03:25
  • 15
    Yes, if you keep Ctrl+Shift held the whole time while typing the numbers, then it will appear immediately. If you release them before typing the numbers (which allows you to also use backspace) then a Space or Enter is required to show the end of the Unicode number input process. – sladen Mar 21 '11 at 03:29
  • Yowza, that's nice: type any Unicode character on codepoint. If only it had a character search capability. – Humphrey Bogart Mar 21 '11 at 12:51
  • @Beau, use the Character Map to search. – Oxwivi Apr 04 '11 at 20:14
  • 6
    Note that this only works for GTK applications. It won't it any Qt-based one, for example (thus the whole KDE and many individual apps like Skype). – Ruslan Sep 05 '14 at 06:31
  • @Ruslan: ISO 14755 is the standard. There appears to be some dispute between QT #8 verses KDE #103788 verses X#26747 regarding how best to get it fixed for Qt applications. A (sub-optimal) workaround would be to entry the character(s) into the Firefox URL bar or Gedit and copy-and-paste it them. – sladen Sep 05 '14 at 13:28
  • @sladen surely it is the standard. But this unfortunately doesn't make it implemented at the right level (i.e. XIM). – Ruslan Sep 05 '14 at 14:17
  • 4
    Mmm... This does not work on Ubuntu 14.04 as Ctrl+Shift+U does not seem to work. Do I need to configure something in keyboard settings? I am testing it with gedit 3.10.4 and Ctrl+Shift+U then 2,0, 1, 4 and Enter displays 2014, and Ctrl+Shift+U+2014 displays )!$ – nephewtom Nov 08 '15 at 01:58
  • 1
    This does not work in Ubuntu 16.04 now that Mir has replaced X11. Help? https://askubuntu.com/questions/768191/how-does-one-enter-unicode-characters-into-systems-with-mir – Aaron Franke May 05 '16 at 22:00
  • 5
    Note that once you type Ctrl+Shift+U an underlined u character appears. I thought this meant I had typed that, instead of the character I wanted. But this is actually a prompt to enter the unicode digits. Once you do that it will be replaced by the character you want. – Steve Sep 15 '16 at 17:42
  • 1
    @nephewtom If you use the numpad, you can hold hold Ctrl+Shift and release when you're done. If you use the number row, you need to release Shift and/or Ctrl before typing in the numbers. If you release both you need to press Enter or Space to confirm. If you release Shift first, then you can confirm by releasing Ctrl when you're done. – Jezzamon Feb 24 '17 at 21:58
  • I need three hands to do that. – Leonardo Castro May 17 '23 at 11:55
84

I could not find a way to type it using AltGr and default settings, but I found another way:

  1. Go to System -> Preferences -> Keyboard.

  2. Select the Layouts tab.

  3. Click Options.

  4. Under Compose Key Position (drop-down), choose a key to use for composing — I chose the Right Win (right Windows key).

  5. 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

  1. Go to System Settings > Keyboard.

  2. Under Typing tab, select Layout Settings link (at the bottom of the dialog box).

  3. Click Options.

  4. Under Compose key position (drop-down), choose a key to use for composing — I chose the Right Win (right Windows key).

  5. Now press and release the compose key, then type --- to get the em-dash.

  • 15
    Note that there is no need to hold the compose key after it was pressed. – sam hocevar Mar 21 '11 at 07:19
  • 4
    I find this method better than the selected answer. It is a lot of easier for both, remember it and typing it. – Fran Marzoa May 08 '13 at 10:26
  • 3
    ubuntu 13.10: System Settings > Keyboard > Shortcuts > Typing > Compose Key – x-yuri Aug 04 '14 at 09:26
  • 2
    This doesn't work with Ubuntu 18.04 – JKHA May 05 '20 at 16:51
  • @Ruslan It's not that unusual. I've never had a UK keyboard without two; the second is right of AltGr, left of the Menu key (RCtrl on the end). I'm sure laptop keyboards and other small keyboards will omit it, but it seems very common on full size keyboards. – Vala Feb 05 '21 at 13:50
  • 1
    @JKHA - I doubt that. Try setting a different Compose key. (For example, in order to avoid interference with keys like Alt, Ctrl or Win/Super, I use the Pause key, which on my laptop is Fn+Right_Shift.) – cipricus Sep 22 '21 at 08:08
  • In Ubuntu 22.04 go to Settings > Keyboard > Compose Key. The default setting (Left Alt) doesn't work, but it you turn off "Layout Default" and switch it to Caps Lock, it will start working. https://askubuntu.com/q/1438008/122045 – odigity Oct 10 '23 at 13:52
22
  1. Go Character Map app (gucharmap, on Applications → Accessories).

  2. Click Search → Find

    screenshot

  3. Type 'em dash' and click 'Find Next'

    screenshot

  4. Double-click the symbol, which will put it in the 'Text to Copy' box at the bottom.

    screenshot

  5. You can then copy-and-paste it where you want it.

    screenshot

Pablo Bianchi
  • 15,657
Nathan Osman
  • 32,155
  • 16
    Or you could just bookmark this page and copy and paste it from the question :) – Alistair Buxton Mar 21 '11 at 00:32
  • 3
    Setting up compose keys is much easier than having to use the character map every time you want a special character. – J. Taylor Mar 21 '11 at 00:38
  • 2
    @jrt: It allows you to insert the character without altering your keyboard layout. Not everyone wants to change their layout just to type a dash. – Nathan Osman Mar 21 '11 at 00:42
  • lol @ comments! – MestreLion Mar 21 '11 at 04:44
  • 1
    I wasn't aware that the Character Map had a search option until reading this. Not sure if I'll ever use it, but +1 for enlightening us.

    (Please vote to delete the "answer" I left below... it was supposed to be a comment here.)

    – trench Aug 31 '11 at 22:39
  • 1
    It's a good idea to combine this (to find the code for your character) with the accepted answer. In ubuntu 16, just type in "character map" in the dash to find the character map and then hit ctrl+f for the find menu – Peeyush Kushwaha May 31 '17 at 10:28
22

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:

  • Right Ctrl--- (in the comments some people say that you must press Control before the hyphens, I can press it simultaneously) (—)

To get the en dash, use Ctrl --. (hyphen, hyphen, dot)

  • Right Ctrl--. (–)

A bonus one, for the … type:

  • Right Ctrl.. (…)

You can configure your Compose key in: settings → keyboard → shortcuts → typing.

neves
  • 1,164
  • 2
    This is the most human method, thanks! You can set the compose key in settings—keyboard—shortcuts—typing. Right control is OK, as it doesn't clash with other modifiers. – metakermit Feb 23 '14 at 16:16
  • 2
    In my browser and shell <(Right) Ctrl>+<-> is a shortcut for reducing the font size, so that doesn't work. – stafusa Oct 04 '18 at 23:10
  • @stafusa - In fact hold control while pressing all the hyphens can be misleading here. You don't have to hold the Compose key while pressing the hyphens etc, it is meant to be pressed and released, that is before the rest. - Already here an even older answer says it clearly. – cipricus Sep 22 '21 at 07:59
  • +1 for the en dash info. But the Compose has to be pressed&released, not held. – cipricus Sep 22 '21 at 08:10
  • 1
    @cipricus Actually, both options work (when they do) — at least in my system, either keeping it pressed or releasing it produces the character. But thanks to calling my attention to it being the Compose key, not necessarily . – stafusa Sep 22 '21 at 11:08
10

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:

enter image description here

Full instructions with pictures here. Summary below. (Also, similar methods here)

  1. Install the python-3 version of Autokey, which plays nicely with Unicode.

    # 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

  2. Run the program. For me it installed to ~/.local/bin/autokey-gtk

  3. Add a "New Phrase"

  4. Add the desired character in the main text box

  5. Add an abbreviation

  6. Profit

Pablo Bianchi
  • 15,657
hugke729
  • 291
  • 1
    For help with this see the AutoKey wiki. There are articles on installation, using Unicode characters, and a number of other topics. There are also lots of example scripts. – Joe Feb 12 '23 at 14:30
5

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.

  1. Identify a key you don't mind remapping. My laptop has a second backslash key, so I used that.
  2. 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.
  3. 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.
  4. 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.
Jonathan
  • 7,450
5

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.

  1. Go to System Settings->Keyboard
  2. Click the Shortcuts tab
  3. Select Typing in the left pane
  4. Set the Compose Key to your desired setting

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

CommandZ
  • 193
  • 1
  • 6
4

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+-.

ændrük
  • 76,794
1

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.

user118223
  • 81
  • 1
  • 1
  • 4