RichEdit Autoformatting

Murray Sargent

RichEdit and Word have had the most elaborate autoformatting ever since Office 2007, namely math formula auto-buildup. A UnicodeMath expression builds up into OfficeMath as soon as it is unambiguous. Word and other programs have also had less ambitious autoformatting since late in the last century. Such functionality includes auto conversion of some simple numeric fractions to composed Unicode numeric fractions, e.g., 1/2 to ½, ordinal superscripts, e.g., 1st to 1st, double dash to long dash, e.g., a--b to a—b, smart quotes, e.g., "word" to “word”, and automatic bulleted/numbered lists. Such autoformatting is available in recent builds of RichEdit since it’s needed for the Office Modern Comments facility. Word and RichEdit have also had autoURL and auto table conversion for many years. The post RichEdit Emoticon Shortcuts – Math in Office ( describes the RichEdit option to convert common emoticon shortcuts to emoji.

Word also supports converting _…_ to italicize the text in the “…” and *…* to bold the text in the “…”. These and some of the other autoformatting notations are reminiscent of Markdown which was invented to enter popular HTML constructs easily in a readable notation. That’s the same rationale that’s behind UnicodeMath for entering math equations and expressions. So, maybe RichEdit should have a Markdown editor option that includes UnicodeMath 😊.

RichEdit’s conversion of simple numeric fractions to Unicode fractions is described in the post Function to get Unicode Fractions – Math in Office ( It supports the whole Unicode fraction repertoire, ↉ ½ ⅓ ¼ ⅕ ⅙ ⅐ ⅛ ⅑ ⅒ ⅔ ⅖ ¾ ⅗ ⅜ ⅘ ⅚ ⅞, whereas Word only handles ½ ⅓ ¼ and ¾. You can create arbitrary numeric fractions using the Unicode superscript and subscript digits along with the U+2044 fraction slash. For example, ⁴⁵⁶⁄₇₈₉₀. Admittedly it’s not great typography, but it works. To enter such characters, it’s handy to have the Alt+x hot key. You can also enter ⅟₁₆, ⅟₃₂, ⅟₆₄, ⅟₁₂₈, and ⅟₂₅₆, where I use ⅟ (U+215F) for the numerator and fraction slash.

To enable RichEdit autoformatting options, send the message EM_SETAUTOFORMAT with wparam = acflgAutoFormat and lparam = 0. The acflgAutoFormat flag can be combined with other flags to disable autoformatting options. The flags and messages are defined by

     acflgAutoFormat = 1
     acflgNoSmartQuotes = 2
     acflgNoSuperscript = 128
     acflgNoEmDash = 256
     acflgNoFraction = 1024
     acflgNoBulletedLists = 8192
     acflgNoNumberedLists = 16384

For the time being, also send EM_SETMSOAUTOCORRECT (WM_USER + 391) with wparam = 1 and lparam = 0. This message enables the RichEdit integration of the shared MSO autocorrect facility. As such, the current RichEdit autoformatting code requires MSO to be loaded, even though the autoformatting code doesn’t use it.


Discussion is closed.

Feedback usabilla icon