is now part of CreativePro.com!

Breaking Very Long Lines with No Hyphens

11

Danielle wrote:

I have a bunch of text that I want to wrap within a text frame without any regard for where the words should break phonetically. I want words to break randomly when the text reaches the right edge of the frame.

What a curious request! I can see that this could make an interesting background pattern or something — basically, text running from line to line without any hyphens at the ends of lines. I can think of one way to create this effect, though you’ll need InDesign CS3 to do it:

1. Place the text cursor in the story and choose Edit > Find/Change.

2. Switch to the GREP tab and set the Search pop-up menu to Story, so that it only affects the current story.

3. Type a period (a dot) in the Find What field (that’s the code for “find any character”)

4. Type $0~k in the Change To field (that’s the code for “the same character you found, followed by a discretionary line break”)

5. Click Change All

Here’s an example of some text… first before:

and here’s what it looks like after the GREP find/change:

Because every character is now followed by a discretionary line break, InDesign will break the line naturally after filling the frame. I hope that helps! Seems like there must be another way to do it; perhaps other people have ideas?

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Eugene says:

    I would have it done it that way too… but only after asking the authors of this site *searches for embarrassment emoticon*

    Yes very clever way, and I have to admit, I submit various queries here that aren’t published, but answered privately, and it’s always a simple solution, although not obvious at the time.

    Ever get that, you’re making a cup of tea/coffee and you can’t find the sugar, you search all over, it’s not there! You ask everyone, eventually someone comes out and helps you find it, because you can’t have tea/coffee without the sugar, well turns out that the sugar was right in front of you all the time and you just didn’t see it.

    That’s what indesignsecrets is, it provides the sugar, the sweeteness to your daily work.

  • Steve says:

    Thanks for the tip! There’s a project I’m working on where this technique would be very helpful. One question though: Does GREP recognize a space as a character? In other words, will it preserve spaces between words?

  • Yes but it still does not solve the problem to cut long URLs but keeping the URL correct when the PDF is exported and to make it clickable.

  • Jochen Uebel says:

    “Seems like there must be another way to do it; perhaps other people have ideas?”
    It depends of what the question was. If “the bunch of text” has to show up completly then I do not know any other technique. thanks for this hint.
    If the goal is only to get a text pattern regardless which characters show up and which don?t we can think of a full text frame which we insert into a smaller graphic frame. Graphic frame is masking text frame.

  • Simon Kemp says:

    I have been looking for a solution to a similar problem myself but in an automated workflow where no user interaction is possible

    Would it be possible to find just the automatic hyphens and replace these with discretionary ones using a script?

  • tmalcom says:

    I had a similar problem a while back and got a similar answer on the Adobe ID forum, except the solution was to use a zero-width space ($1\x{200b}), rather than the discretionary linebreak. The problem was getting a long DNA sequence to break without hyphens and it worked like a charm.

  • Adam Twardoch says:

    Of course using a discretionary line break is better than using zero-width space, because the discretionary line break does not change the character string while the zero-width space does, so if you generate a PDF from the document, things like Find in Acrobat or PDF search by Google or Spotlight may not work as you’d expect it.

    A good example of two cases that may produce the same result visually but do not actually do the same thing. When making PDFs for electronic distribution, it _does_ matter what the underlying character string is, not just what the glyph stream on screen looks like.

    Regards,
    Adam Twardoch

  • Harbs says:

    Adam,
    Hmmm. I’m not sure I’d want to disagree with you on a topic like this, :) but I thought the discretionary line break IS a zero width space (\u200B)…

  • Nathan says:

    Thank you so much! I am making type specimen’s and this saved the day!

  • David uttah says:

    Great article. Simple four line article is saving amount of time. Thanks for sharing.

  • mathias says:

    Cool tIp! Still handy!

  • >