I'm working on typesetting a book in InDesign that has verses. Each verse starts with a number. The numbers can't be at the end of the line as it is the beginning of the text on the next line. I learned here that GREP styles would be able to do this. I just don't know how to set up the grep style to find the numbers and move them to the next line.

Here's a sample block of text with the numbers in question highlighted: sample block of text

Also, a side question - would it be possible to apply a character style to a specific type of text in InDesign using GREP? I'm currently applying character style manually to each number :|

Thanks guys!

  • Its easy enough to create a GREP style to apply a Character style to your number - but if you create a rule that applies a hard return to any number that is in a Justified paragraph, what will you do about the verse number that is in the middle of your sentence?
    – Mark Read
    Sep 6, 2019 at 5:40
  • That's a good point! I wish there was a way to set a rule that if that word was at the end of the line, push it to the next line without a hard return...almost like orphan rules push stuff around without needing a hard return anywhere.
    – GhFan
    Sep 6, 2019 at 20:47

1 Answer 1


Grep styles are designed to apply character style to a specific pattern. They don't allow you to replace a character by another one. In your case, you might think that you should replace the normal space after numbers by a non-breaking space (NOT a hard return!).

But you can create a character style in order to format your numbers, the dot and the following space and set the whole thing as "non-breaking":


could do the job. Be aware this regex will apply the grep style to all numbers if followed by a dot and a space, so be careful.
If you don't want the space to be styled like the numbers (smaller font size, background color, etc.) then you'll need to create 2 characters styles: one for the numbers and the dot, and one for the space (if preceded by number + dot).

Grep are great but very picky, so it's almost impossible to give the perfect answer without seeing the entire design.

  • Its not that regular languages are picky. Its just that computers are dumb as stones (which is not terribly suprising they are made out of tge same stuff). So they will do exactly as told, which is picky.
    – joojaa
    Sep 6, 2019 at 15:36
  • 1
    You would probably be wise to google for Scripture Typesetting (if this is what your example is) there seems to be a few scripts and tips that pros are sharing.
    – Mark Read
    Sep 9, 2019 at 1:29
  • Thanks for your clarification Vinny. Would it be possible to do this by finding characters that match the dot and that are at the end of the line and then applying a chacter format that increases the tracking on the first character sufficiently to promote it jumping to the next line? This way it doesn't apply this character style to all instances of it. Hope I'm making sense.
    – GhFan
    Sep 9, 2019 at 13:16
  • Mark Read, thanks for the suggestion. Didn't think about that! I'll definitely look those up.
    – GhFan
    Sep 9, 2019 at 13:17
  • 1
    @GhFan Grep style can't catch characters based on this kind of location (end of line).
    – Vinny
    Sep 9, 2019 at 14:01

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.