the comma in Chinese is different from that in English. But they are too similar.

correct English comma

enter image description here

incorrect Chinese comma

enter image description here

As a non-English user, we have to switch the input quite often. If I type a Chinese comma in a large block of code by mistake, my god! sometimes it kill a lot of time to find what is wrong.

I previously write a suggestion to wolfram support to make Chinese comma stand out, so I can easily catch it. They claimed that they will consider it.

But it is already M11 now, things are even getting worse. The commas are more similar in the new font!

So I can not wait, is there a way to customize syntax highlighting to make a particular symbol colored, bigger, or whatever to make it stand out?


2 Answers 2


You may use the InputAutoReplacements option. It has been around since version 4 according to the documentation.

By changing the comma "," with the Chinese comma below then a notebook will be created that replaces the Chinese comma with the text "ChineseComma" whenever it is typed. Actually when the next character is typed after it is typed.

CreateDocument[{}, InputAutoReplacements -> {"," -> "\"ChineseComma\""}]

Note that if you change "\"ChineseComma\"" to the English comma, "," then it will replace inline for you. I think the following has the Chinese comma and does the inline replacement.

CreateDocument[{}, InputAutoReplacements -> {"," -> ","}]

You can also set this from the Format | Options Inspector. Then select Global Preferences for "Show option values". Next highlight "Editing Options" and update the InputAutoReplacements option setting in the option list. This will enable the replacement in all notebooks by default.

Note that the above will only replace on typing in the character. If you copy and paste in a Chinese comma it will not replace it.

Hope this helps.

  • $\begingroup$ Hi, Edmund. Thanks for answering. Are you using M11? I tried all your solution, but didn't work. and for the last method, I can't find "Show option values" $\endgroup$
    – matheorem
    Commented Aug 26, 2016 at 6:06
  • $\begingroup$ @matheorem Does it work for you when you try it with comma as in the first statement. You have to press another key after you type the comma for it to do the replacement. I'm using version 11.0 as well. The first statement works for me. I could try the second as I don't know how to type a Chinese comma. However it should work the same. $\endgroup$
    – Edmund
    Commented Aug 26, 2016 at 11:42
  • $\begingroup$ I know what is going on. ","->"," works, while ","->"," doesn't work. It seems that M11 has built in check of Chinese comma, look at this pasteboard.co/dkoesa41o.png If I type a Chinese comma, the system has a drop down, I don't what is this drop down designed for, well, it does "warn" me I type a wrong comma. And it also makes InputAutoReplacements disabled. Do you have any idea to overcome this? $\endgroup$
    – matheorem
    Commented Aug 26, 2016 at 15:06


   $PreRead = ReplaceAll[#, "," -> ","] &;

This replaces the Chinese comma once you evaluate an input line:

enter image description here

The following quote from the $Pre documentation is useful:

$Pre is applied to expressions, while $PreRead is applied to strings which have not yet been parsed into expressions.

There is also a useful discussion of $PreRead in the Global Aspects of Wolfram System Sessions tutorial. See also the $PreRead documentation.

  • 2
    $\begingroup$ Thank you so much for answering. +1. I would even suggest define something like badComma::error = ""; and then define $PreRead = ReplaceAll[#, "," :> Message[badComma::error]] &;. In this way, it warns me and I can trace back where I input the wrong comma and fix it. Let's see if there are even better solutions that explicitly hightlight bad comma :) $\endgroup$
    – matheorem
    Commented Jul 24, 2022 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.