Every so often, the question is raised how to add delimiters (commas, or thin spaces, etc.) between groups of 3 digits in long numbers in InDesign.
It would seem like this is something a clever GREP search could do, but in fact it is not so easy as it seems. In fact, I’m not sure it’s possible with a single simple GREP.
However, it is certainly possible with a script.
To use the script below, select something GREPable (text, a text frame, etc.), and run. Choose from the dropdown list the style of formatting you want. The available options are based on The Chicago Manual of Style (15th edition, chapter 9.23).
You can also choose to ignore numbers that are only 4 digits long (this might be useful to avoid formatting 4-digit years as well).
Click here to download the script: FormatLongNumbers
Here’s a screenshot.
Have fun!
Rainer
August 17, 2018 12:12 pmThanks for the script, and thanks to F van der Geest for the
G = delimiterDropdown.selection.index ? “.” : “,”;
I’m working in Germany and sometimes we also insert periods instead of spaces.
Vaibhav
May 7, 2018 4:32 pmHey thanks for the script that was really helpful
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678.09
123456789.00
1234567890.04
i have to insert commas in indian value example
1
12
123
1,234
12,345
1,23,456
12,34,567
1,23,45,678
12,34,56,789
1,23,45,67,890
1,23,45,678.09
12,34,56,789.00
1,23,45,67,890.04
can you please help me
Micheal Angelo
December 13, 2017 5:49 pmHow about adding comma on pages, like when it reach 1,000 and so on. InDesign doesn’t support comma for pages but people here might have an idea on how to do that. Thanks in advance guys.
Ariel
December 13, 2017 8:43 pmHi Micheal,
The problem there is that page numbers are not actual numbers — they’re a single character that InDesign displays as a number, according to the page formatting you’ve chosen. So they’re not susceptible to a find/change operation, unless they’re somehow converted into regular text.
Ginger Marks
October 19, 2016 4:35 amIs it possible to make monetary changes as well? $###,###.## and while you are at it foreign currencies?
Tanvir
September 8, 2015 6:14 amHey thanks for the script that was really helpful
i have to insert commas in indian value example 1,00,00,000
can you please help me
Admin
September 8, 2015 5:13 pmHi Tanvir,
I’m not familiar with that system. Can you explain a little more?
F vd Geest
November 30, 2014 5:04 pmSorry, typo yes, 12.345 etc. My bad, you are right.
F van der Geest
November 28, 2014 8:33 pmI opened up the script and changed the line:
G = delimiterDropdown.selection.index ? “.” : “,”;
This works for European numbers
F van der Geest
November 28, 2014 8:29 pmUsing European style we use points:
So
12340
Should turn into:
1.2340
NOT a thin space
Admin
November 29, 2014 7:45 pmHi Frans,
Thanks for your comment. But there must be a typo in what you wrote? I presume you mean 12340 should turn into 12.340?
If so, then you should complain to the Chicago Manual of Style, whose advice I followed. For European style, they give this example:
36 333,333
(meaning thirty-six thousand, three hundred and thirty-three point three three three).
Are they wrong?
Lindsey Thomas Martin
January 6, 2015 7:58 amThis is the style advocated by Le Ramat and the Lexique des règles typographique. It does not necessarily apply to languages other than French. Here, as elsewhere, the advice of the Chicago Manual suffers from a certain foreshortening.
Admin
January 8, 2015 3:53 pmThanks for those details. So it does sound like we need 4 options: (1) US & British; (2) Canadian; (3) Continental Europe; and (4) French.
Well, when I get a chance I shall try and update the script. If anyone else wants to create this fourth option, feel free and I’ll post the revised version.
Max
June 9, 2022 12:47 pmJust stumbled over this page and I’m 7 years late for the party. Just correcting this part here for others to see.
The 36 333,333 is used in Sweden where I live and also in Albania, Belgium (French), Bulgaria, Canada (French-speaking), Costa Rica, Croatia Czechia, Estonia, Finland, France, Hungary, Italy (in education), Kosovo, Latin Europe, Latvia, Lithuania, Macau (in Portuguese text), Mozambique, Norway, Peru, Poland, Portugal, Russia, Serbia, Slovakia, South Africa (in Afrikaans text), Spain (official use since 2010, according to the RAE), Switzerland (officially encouraged, except currency numbers[52]), Ukraine, Vietnam (in education).
https://en.wikipedia.org/wiki/Decimal_separator
Thiago Ribnog
November 24, 2014 2:43 pmNice one! But please, in my country we use dot instead common like 4.500 etc.., If I want to change the dot for a thin space. There’s a way to do that? Help me. Thank you.
Admin
November 24, 2014 3:04 pmIf it’s just a question of changing an existing period to a thin space (rather than separating groups of digits with commas or thin spaces) you can probably get by with a simple GREP:
Find: (\d)(\.)(\d)
Change: $1~<$3 I think that should work, though I haven't tested it (but be careful: it could mess up a number of things, including URLs and file names!)
Thiago Ribnog
November 24, 2014 5:00 pmThank you for the fast response! I’ll try it!
David Blatner
November 21, 2014 12:19 amThis looks great. Thanks! Glad you can ignore 4-digit numbers. Years ago, when I was working on Judaism For Dummies, all the history chapters came back from the editor with commas in the dates, like “the year 1,492.” They must have used some sort of macro.
Admin
November 24, 2014 3:00 pmThanks David. Sure, I think the 4-digit thing is useful. Although right now it’s an either/or proposition — if you don’t want a comma in years, but you do want it elsewhere, you’ll have to run the script twice.