Reordering Paragraphs With GREP in InDesign

Ever have a sequence of paragraphs that you needed to put in a different order? If it's just one or two paragraphs, you could copy and paste. But what if you need to make the same change dozens, or even hundreds of times? In that case, it's time to use a little GREP Find/Change. The key is to use the Found Text expression.

Here's a sequence of paragraphs of contact information.


Say you needed to rearrange the last two paragraphs so the email address comes before the Twitter handle. No problem.

Open the Find/Change dialog box and click on the GREP tab. In Find What, search for a sequence of five paragraphs using the expression, one or more of any character, followed by an end of paragraph .+\r

Enter this five times and put each one in parentheses to group them into separate sub-expressions.



Now rearrange the sub-expressions by replacing them with the code for Found Text 1-5, indicated by dollar sign plus the number. And simply put the fifth found item $5before the fourth $4.



Run the find/change and voila, the information is reordered.



The one "gotcha" you have to be careful of is that GREP find/change will mess up any text formatting you have applied to individual words or paragraphs. So you should do this before you apply formatting!

No comments: