Members Only

GREP of the Month: Locations

Tips on how to narrow your GREP searches and styles to specific places in a paragraph or story in InDesign.

This article appears in Issue 67 of InDesign Magazine.

Where you search is sometimes just as important as what you’re searching for. When it comes to GREP queries, InDesign will look through an entire paragraph unless you include code to narrow the search to a specific location. If you know that what you’re looking for is at the beginning or end of a paragraph, you can use the ^ symbol (Beginning of Paragraph) or the $ symbol (End of Paragraph), found in the Locations metacharacter submenu. So if you want to remove all white space at the start of each paragraph, use ^s+ and keep the Change to: field empty. You can find trailing white space at the end of paragraphs using s+$. The ability to target the beginning or end of a paragraph allows you to easily add desired content in those places. Just remember that to add new content with Find/Change, you need to first find some existing content. Using only ^ or $ will place your cursor at the right location, but it will not select anything. For example, to add an em dash followed by a thin space at the beginning of a paragraph, you need to find ^. (the period matches any single character), and replace with ~_~<$0. Here, the $0 stands for Found Text (everything we find, we put back in after the em dash and thin space).

This GREP search adds a period at the end of each paragraph that doesn’t end with any punctuation. In this example, the ^ means “not” because it is inside brackets.

The same is true for adding content at the end of a paragraph. Suppose you have a bunch of one-sentence paragraphs and you want to add a period at the end of the ones

that don’t have any punctuation. For that, you can use [^[:punct:]]$ which translates to “anything that is not punctuation at the end of the paragraph” and change to $0. If you want to search for something at the beginning or the end of a story, you can also use special metacharacters (not available in the Locations submenu): A for the beginning of story and z or Z for the end of a story.

More Resources To Master Type and Typography

CreativePro Week is the essential how-to conference for creative professionals who design, create, or edit in Adobe InDesign, Photoshop, Illustrator, Acrobat, and Microsoft PowerPoint.

Featuring over 30 expert speakers and 75 sessions and tutorials, CreativePro Week offers five days of in-depth training and inspiration, all in one place. No matter your skill level, you’ll learn techniques and best practices you can start using immediately to improve your productivity.

LEARN MORE

Members get a special discount on registration! Sign up today.

Bookmark
Please login to bookmark Close

Not a member yet?

Get unlimited access to articles and member-only resources with a CreativePro membership.

Become a Member

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading comments...