Members Only

GREP of the Month: Horizontal and Vertical Spaces

Erica Gamet offers some easy to remember codes you can use to quickly select any kind of whitespace.

This article appears in Issue 64 of InDesign Magazine.

If you use GREP in InDesign, you either know the name Peter Kahrel or you should. He literally wrote the book on using GREP in InDesign. I had the pleasure of meeting him in person at this year’s PePcon (in my GREP session, so no pressure there). He let me in on a little addition to InDesign’s subset of GREP expressions that goes back to CS6: the wild cards \v and , that represent vertical and horizontal white space, respectively.

The \v wildcard will find both hard and soft returns, so it can be used in place of the [\r] expression. However, the expression has even more promise in that it will find all white space except for the return character \r. That will make looking for two or more spaces even easier.

The built-in GREP expression for “multiple space to single space” looks for [~m~>~f~|~S~s~<~/~.~3~4~%]{2,}, which looks for each specific type of white space when there are two or more together. We’ve always been able to simplify it as {2,}, but unlike the previous expression, that will also find—and change—multiple returns.

Using the command, that expression can be written more simply as {2,} which will find everything from the first expression, as well as multiple tabs in a row, but not the multiple return characters.

For those who use GREP for text cleanup a lot, this could be a huge timesaver. If you’re not using at least the built-in GREP expressions to automate with InDesign, what are you waiting for?

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 *