Merging Paragraphs with Find/Change
Ginny wrote:
I’ve imported 40 pages of directory listings each with a hard return at the end of a line. Is there a way to globally change the hard returns to soft returns, or forced line breaks, once the text is imported from a word doc into InDesign?The goal is to separate each member’s info with a space after attribute using the hard return, with the rest of each members info spaced with leading only.
This requires a tried-and-true technique: A triple Find/Change.
Lets take some sample text, as you described:

It’s easy to replace a return with a soft return in Find/Change, (Find: ^p, Change: ^n) but that’s usually going overboard. You end up with one monstrously long paragraph with no easy way to break them up into smaller ones.
So you start out by figuring out what unique thing — a text string, a character style, a certain number of returns — only appears immediately before or at the beginning of your “real” paragraphs and on no others. Then you use Find/Change to temporarily replace that unique identifier with something that doesn’t contain any return characters. I often use %%%.
For the sample above, the “real” paragraphs are identified by two returns in a row (pretty common). So we replace that identifier with a unique string.




The third and final Find/Change replaces the unique paragraph separator we added with an actual return character.


So now you can easily select all the text and apply paragraph formatting, such as Space Before, that does what you want it to.

See, easy solutions like this is why I love this blog! Thanks
Hi Anne-Marie,
why not doing this in two steps?
1. Replace ^p with ^n
2. Replace ^n^n with ^p
Martin
Hi Martin
why not doing this in one step?
1. Grep-Replace \r(\r*) with \n$1
Martin
(Sorry, I’m a little bit schizoid this morning…)
This is great!
I did it the long way some days ago!
Thanks for sharing this!
Best regards from Austria
Martin
…by the way, are there some free ebooks and/or other resources out there to really lern GREP?
Martin
I always do it the way Martin Braun suggested (the first one :P) and it works great.
Hi Martin (the “not me” one),
I learned Grep with the Documentation that ships with BBEdit (a Mac-only-application). You can download a demo at http://www.barebones.com.
Meanwhile I improved the search-pattern:
grep-replace \r(\r?)\r* with \n$1
This will strip out unnecessary paragraphs.
Yes, GREP is by far the fastest way here
>…by the way, are there some free ebooks and/or other resources out there to really lern GREP?
Martin
Yes, take a look at O’reilly, They have a great PDF on GREP in InDesign (not free however)
If you have lots of time and no money, Google “GREP.” There are lots of resources, though not oriented to InDesign.
If your time is worth money, it’s worth paying for something well-written.
Well I wondered how long someone would put up a GREP solution that’s faster.
Still, not everyone has CS3 or is in a position to export text to a GREP-ready text processor for this; so the plain old F/C works just as well.
For a great GREP resource, don’t forget Peter Kahrel’s wonderful PDF e-book, GREP in InDesign CS3. Well worth the $9.99! I wrote about it in a blog post a couple months ago.
>or a great GREP resource, don’t forget Peter Kahrel’s wonderful PDF e-book, GREP in InDesign CS3. Well worth the $9.99!
That is the one I meant, see O’reillys
3 step find and change — good
2 step find and change –better
1 step grep –best
1 step grep that fixes my lunch –amazing
I wonder, has anyone written a book that explains problem solving techniques? How to THINK through problems, APPLY what they know, and USE available resources to come up with the most amazing solution?
Not that the book has to be geared toward any particular application or platform, just something that can help people learn to be problem solvers and make the most use of what they have.
I have seen people who can’t even attempt anything similar to this. (They can’t think outside the box.)
And some who spend their time outside the box when what they need is to realize the box has everything they need.
I second Peter Kahrel’s e-book. Well worth the $9.99 and then some.
I didn’t notice that the OP specified that each entry set was separated by a double hard return after the Interest: line. Too me the problem’s a bit of a no brainer given the double hard return. What if you only had the word Interest: to key on? Or maybe I’m misreading something here.
The thing about “no-brainers” is that they’re only no-brainers to people who forgot they too, at one point, needed to figure it out. Note the category for the post: Beginner’s Corner.
If you only had the word “Interest” to key on, then instead of replacing two returns in a row with the %%%, you’d replace one return followed by the word “Interest” with “%%%Interest”.
To Andrew Herzog
How to think!
Edward De Bono has written numerous books on how to think.
check it out!
Seems to me that using %%%Interest you are going to end up splitting off the interest and adding it to the following name. Perhaps it would be better to find all instances of Interest and apply a new paragraph style name to that paragraph, then find any other style and change the paragraph return to a line break (bear in mind I haven’t tested this).
Peter
Hi Peter,
your solution with paragraph styles ist great and works in CS3 and older Versions. A geeky grep way in this case is the “negative lookahead”. Try this (and be amazed):
Search: ^((?!Interest:).*)\r
Replace: $1\n
Greetings from Germany
Martin