MS Word Tip: How to Replace Hyphens with En Dashes

Though most people don’t know (or care when told), the correct character to use for a range of numbers is the en dash (–), not the hyphen (-). Even if you’re committed to using en dashes between digits, hyphens are a tad easier to type,1 making a find and replace necessary at some point. If you’re diligent and use the en dash faithfully, you will undoubtedly get a rogue hyphen in there somewhere if you do any copying and pasting from the internet or other documents that don’t consistently use the correct character.

A simple find and replace (- for –) would do the trick—if you wanted to replace all hyphens with en dashes. But you don’t want to do this, since hyphens in hyphenated words are correct. :) Alternatively, you could run that query but, instead of replacing them all at once, replace one at a time only the ones that appear between digits. But this could be time consuming on a large document like a dissertation. Another option would be to set up a query to find 0-0 and replace it with 0–0, then 0-1 with 0–1 and so forth, but that would require 100 different searches and probably take longer than the previous method! The previous method could probably be simplified by dropping the second digit since there aren’t likely to be any instances when you’d have a digit followed by a hyphen not followed by another digit. That would make only 10 find-and-replace queries. So this is as least doable, though still not ideal.

Fortunately, there is a better solution than any of these.

What we want to do is find any single digit followed by a hyphen followed by another single digit and replace the hyphen with an en dash, leaving the digits unchanged. I tried to use the special digit character, ^#, and came up with a query like find ^#-^# and replace it with ^#–^#, but this didn’t work because ^# is not valid in the replace field.

I knew there had to be a way to do it, but I couldn’t figure it out. So I went to Google and found my answer in just a minute or two.

Here’s what you do:

  1. In the “Find what” field, enter ([0-9])-([0-9]).
  2. In the “Replace with” field, enter \1–\2 (note that that’s an en dash, not a hyphen).
  3. Check the box “Use wildcards.”
  4. Click “Replace All.”

Replace Hyphens with En Dashes in Word

That’s it. Much easier than any of the other methods. See the article for more details and an explanation of the search syntax.

Footnotes

  1. To type an en dash in Word, you can either use the default key combination Ctrl + – (the one on the keypad) or create your own shortcut. My shortcut is Ctrl + – (the one on the main part of the keyboard).

, , ,

34 Responses to MS Word Tip: How to Replace Hyphens with En Dashes

  1. Ryan Burns January 30, 2009 at 8:30 pm #

    Two things: First, I know that you were thinking of me the entire time you wrote this post, and that I was the reason for the parenthetical remark in the first sentence. Second, I know that you knew I would comment on this post—you were right. However, did you expect that I would pepper my comment with egregious misuses of the dash? I thought not.

    • Phil Gons January 30, 2009 at 8:57 pm #

      Well, I have to admit, you did come to mind when I wrote this, but “the entire time” is a bit strong. And, yes, I did have you particularly in mind with the “don’t care” bit. :) However, I didn’t expect you to comment (you read my blog?), and I really didn’t expect you to so horribly abuse the hyphen, en dash, and em dash in your comment.

      Hey, I bet you didn’t expect me to edit your comment to clean up those egregious errors, did you? Or maybe you did. You know me too well.

  2. Ryan Burns January 30, 2009 at 10:00 pm #

    Dang it! You’re good. A little too good.

  3. Lawrence January 31, 2009 at 1:11 am #

    Alternatively, to insert an n-dash in almost any program simply hold down the ALT key and type 150 on the numerical keypad (assuming number lock is on, of course). The nice thing about this approach is that you can do it for any ANSI/Unicode character (e.g. ellipsis = 133, m-dash = 151).

    • Phil Gons January 31, 2009 at 8:33 am #

      Lawrence, thanks for the tip, but when I try these I get û, à, and ù respectively. I get this is Firefox, Outlook, Word, etc. I think you mean 0150, 0133, and 0151, which do produce the behavior you’re talking about.

    • Mark May 7, 2013 at 11:41 pm #

      For those Linux users out there, there are lots of ways to enter en dashes and em dashes. In some distributions you can hold ctrl and shift and press u while you do that. Then an underlined u will appear. Then type in the Unicode hexadecimal value for whatever Unicode character you want, and it will appear.

      An easier and faster way to do common special characters (not every single Unicode character) is to set up your compose key. In Debian and Ubuntu with GTK 2, go to keyboard, layouts, and enable the compose key. In Xfce (or Xubuntu or whatever), you can set up a script and set it to start up with your machine, with this content, which will enable it:
      #!/bin/bash
      setxkbmap -option compose:lwin

      In this case, the left windows key is the compose key. The compose key is easy to use, once set up. To type an em dash, just press the compose key and then the hyphen key three times. To do an a with an accent press compose then apostrophe then a. Anyway, I’m making it sound more complicated than it is, I bet.

      Does the same syntax for replacing the en dashes work in OpenOffice (and LibreOffice, which is pretty much the same thing)?

      Also, how do you avoid putting en dashes in phone numbers and stuff like that? If you could search to make sure there aren’t more numbers and dashes around, that would be great. Any idea how?

      • Mark May 7, 2013 at 11:48 pm #

        Type an en dash with compose hyphen hyphen period.

        The Unicode hexadecimal representation of an en dash is 2013 (u+2013).

        Anyway, phone numbers require figure dashes (u+2012). I don’t know that most fonts even make them look any different, though. You’d have to check. Figure dashes are supposed to take the same amount of space as a number: 1‒234‒567‒8910

        Even less people use figure dashes than en dashes.

  4. Jack Caviness January 31, 2009 at 4:03 am #

    Phil

    In Word for Mac, (2008 & Word X), this did not work for me. I receive an error message: “The Replace With text contains a group number which is out of range.” This happens no matter how I enter the en dash, and even when I only enter “\1″ into the “Replace with” field.

    Since I skipped Word 2004, I could not try it there, but I assume it would work like the other two.

    Jack

    • Phil Gons January 31, 2009 at 8:37 am #

      Jack, did you try the couple of suggestions in the article?

      Note: if this formula doesn’t work, try using (< [0-9]@>)-(< [0-9]@>) instead.

      Note: If you have been using Track changes . . . , you will need to turn it off before using this Find and Replace procedure, otherwise it won’t work properly.

      If these don’t help, I’m not sure what to suggest.

  5. Peter G. January 31, 2009 at 12:06 pm #

    Phil,
    This is good to know. I knew there had to be a way to do this but had never taken the time to find out. In my own papers I have simply been inserting en-dashes manually each time using the same shortcut you mentioned. But putting this search & replace function into a macro will be nice for other people’s documents (e.g. my professors’ syllabi).

  6. Justin Taylor February 2, 2009 at 8:21 am #

    Ah…you couldn’t have posted this before we edited the ESV Study Bible?? :)

    JT

    • Phil Gons February 4, 2009 at 7:31 pm #

      Sorry about that, Justin. :) (Just pulled your comment out of SPAM.)

  7. Phil February 2, 2009 at 11:38 am #

    Download and install AllChars, a wonderful applet for the PC that facilitates inserting all the off-keyboard characters.

    http://allchars.zwolnet.com/

    • Phil Gons February 2, 2009 at 8:15 pm #

      Thanks, Phil. How does AllChars differ from Character Map in Windows or BabelMap?

  8. threegirldad February 2, 2009 at 12:32 pm #

    On the other hand, you just might end up wishing that you had left well enough alone – such as, for example, after “correcting” an electronic One Year Bible Reading plan only to discover that a certain online Bible site ([cough]ESVSB[cough]) “throws a rod” if an en-dash rather than a hyphen is part of the Search string.

    Ahem…

  9. Andrea February 2, 2009 at 1:00 pm #

    Mr. Gons,

    Any shortcuts for a laptop without a number pad? It’s a little tiresome to let auto correct do it by typing “number space hyphen space number space” and delete the spaces. I guess I could just find and replace now though. Thanks.

    I’ll add this to “Omega always wins” in my list of things I learned from you.

    Your former student,
    Andrea Crocker

    • Phil Gons February 2, 2009 at 8:21 pm #

      Andrea, nice to hear from you. Please greet your husband for me!

      In Word you can set your own shortcut. As I mentioned, I use Ctrl + – (the one next to 0). Alt 0150 has the advantage of working anywhere without needing to create a shortcut. Find and Replace at the end of a large document is a good way to go. For shorter documents, it’s probably not worth it and best to use one of the shortcuts for typing it.

      Did I really say that? I hope there is more on your list than this and that statement, or I’d feel like a pretty lousy teacher!

  10. Larry February 2, 2009 at 5:41 pm #

    If I remember correctly, in Word 2003 (and probably others as well), if you are using a full size keyboard, cntrl the dash (or minus sign) on the number pad does the en dash.

    I don’t have my full size keyboard here to try, but if you have one, I am pretty sure this is the combination. It is easier than the alt-150. BTW, alt 151 is the em-dash.

    • Phil Gons February 2, 2009 at 8:26 pm #

      As I mentioned in my post, Ctrl + – (the one on the keypad) is the standard MS Office shortcut for the en dash. You can also create your own, which I make Ctrl + – (the one on the main part of the keyboard).

      As Lawrence pointed out in his comment and I corrected in mine, Alt 0150 is the key combination for the en dash and Alt 0151 for the em dash.

  11. Phil February 3, 2009 at 2:47 am #

    The applet AllChars runs in the background. When you hit the Ctrl key, it awaits two characters and will then turn that into a character. For instance Ctrl-n-hyphen outputs an en dash, and Ctrl-m-hyphen outputs an em dash. Or Ctrl-x-x gives a multiplication sign. It’s pretty cool.

    • Phil Gons February 4, 2009 at 7:29 pm #

      Good to know. Thanks, Phil.

  12. Larry February 3, 2009 at 5:12 am #

    I missed your footnote there somehow, Phil. My apologies. You had already said what I said.

    • Phil Gons February 4, 2009 at 7:13 pm #

      No problem, Larry. Someone else may have as well, so it doesn’t hurt to repeat it. Sorry for my matter-of-fact (i.e., less-than-kind reply). :(

  13. Mark Snoeberger February 3, 2009 at 5:43 am #

    Wow, a serious blog exchange about en dashes…with 16 entries, no less! The world is becoming a better place. It must be Obama. I have tears in my eyes.

    Seriously, this is a helpful trick, Phil, and I have used it teaching Theological Research Methods here at DBTS. Unfortunately, a few errant hyphens can still get through, such as date ranges that use months (like Bibliotheca Sacra and others) and Roman numerals. For this reason I still recommend that students use the simple find and replace (en dash for hyphen) and choose the one-at-a-time option.

    MAS

    • Phil Gons February 4, 2009 at 7:29 pm #

      Thanks for the comment, Mark. Good points. I wonder if Word is robust enough to handle a regular expression that could account for months and Romans numerals. There are a number of people at work who are very skilled with regular expressions. I may have to check with one of them to see what that would look like.

      Any other exceptions that you can think of?

  14. Michael February 4, 2009 at 12:59 pm #

    Hmmm… I left a comment on this post the other day and it has magically disappeared.

    • Phil Gons February 4, 2009 at 6:34 pm #

      Michael, let me take a look in my SPAM filter to see if it got sent there.

    • Phil Gons February 4, 2009 at 7:24 pm #

      Sorry, Michael. Couldn’t find it. I never check through my SPAM. I just get too much. But I just looked through the last several hundred and, while I found four comments from others, I didn’t see yours.

  15. Valentin May 12, 2009 at 3:48 pm #

    Awesome tip, works in OpenOffice as well (check the option ‘regular expression’).

  16. Justin Taylor January 4, 2010 at 12:24 pm #

    Phil,

    Thanks again for this tip, which is incredibly handy.

    One thing to watch for: I think this formula will miss entries like Matt. 1b-2.

    Blessings!
    JT

    • Phil Gons January 4, 2010 at 7:51 pm #

      You could modify the first line to ([0-9a-z])-([0-9]). This would find any number or lowercase letter followed by a hyphen followed by a number. This might be too sloppy though, but I can’t think of any cases where you’d have a letter followed by a hyphen followed by a number where you wouldn’t want to use this find and replace. Let me know if you can think of one. If you can, it’s possible to tweak it further to require a number followed by a letter followed by a hyphen followed by a number. But I might need to get my wife’s help for that one.

  17. Tim Bulkeley June 17, 2010 at 2:16 pm #

    When I tried this in Open Office what happened was that things like: 1:3-2:16 became monsters like: 1:\1–\2 :16. (Yes I did tick “regular expressions”.)

  18. Chuck January 7, 2014 at 6:38 am #

    I had a different but related problem, and this very helpfully solved it. Thank you! Once I got all the details correct, my very large document found and replaced 189 instances in about a second. Bravo!

  19. Rick June 10, 2014 at 11:52 am #

    I’m running Word 2003. I have a document of about 200,000 words and have to replace a dash for an en-dash. When I put in cntrl + – in the replace box for Find and Replace, nothing happens, over and over. Auto correct has the box marked for replacing dash for en–dash. Alt 0150 doesn’t help either. There has to be another answer for this because your solution won’t work.

Leave a Reply