Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Selecting Horizontal and Vertical Spaces With GREP

by Erica Gamet

If you use GREP in InDesign, you either know the name Peter Kahrel or you should. He literally wrote the book on using GREP specifically 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 sub-set of GREP expressions that goes back to CS6. The wildcards \v and \h 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\n] expression. However, the \h 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 \s{2,}, but unlike the previous expression, that will also find—and change—multiple returns.

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

ids_20140714-horizgrep3

For those who use GREP for text clean-up 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?

Tags
Related Articles
Comments

7 Comments on “Selecting Horizontal and Vertical Spaces With GREP

  1. Great post, Erica! I use the Multi-Find/Change extension for a lot of text clean-up. I need to wrap my head around this and see if I might not be able to combine multiple steps into one. Thanks!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>