GREP of the Month: White Space
Learn how to find and replace any white space characters in InDesign.

This article appears in Issue 84 of InDesign Magazine.
Poor white space, it never gets the credit it deserves. Think about it: without spaces, your text would all run together and you wouldn’t know where one word ended and the other began. According to the book Space Between Words by Paul Saenger, separating words with spaces didn’t really catch on until the tenth century; before that, it was up to the reader to decide where one word ended and the next began. Fun!!
Space between words is called “white space” because there’s no visible glyph; it’s the absence of ink. You may think there’s only one kind of white space—the kind you get by hitting the spacebar. Wrong! InDesign’s GREP allows you to search for and replace a dozen different kinds of white space, from the spacebar-created ones to complex constructs like figure spaces; to see them all, open the Find/Change dialog box, click the @ symbol, and then choose the White Space menu item. You can search for these white space characters the same as any other character.
Let’s say you’re a designer who likes to use en dashes with a space on each side – like this. But some smart aleck comes up to you and says you should really use nonbreaking spaces, so that your dash doesn’t accidentally wrap to the next line.
Type ~=
in the Find What field and ~S~=~S
in the Change To field to change all those ordinary spaces to nonbreaking ones.
That character (“any white space”) is also handy if you want to change every instance of more than one space to a single space. Find
{2,}
and change to . The
{2,}
construct means “anything with two or more consecutive.” Or you can use InDesign’s built-in Multiple Space to Single Space query,
which does the same thing in a more verbose way.
Parting tip: When playing with spaces, it’s best to turn on Type > Show Hidden Characters.
Commenting is easier and faster when you're logged in!
Leave a Reply
Recommended for you

Illustrator Downloadable: Summer Citrus Pattern Set
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

InDesign Downloadable: Tables SuperGuide
Downloadables are an exclusive benefit for CreativePro members! (Not a member ye...

How to Be a Better Designer: Learn About Type
It’s all about the type. Or, as James Carville might have said, it’s the typogra...
Hi Chuck, Thank you.
I am working on a publication which contains a passages in Japanese. When When English text in italic (character style) is followed by Japanese text (character style), the (roman) space in between looks too tight. I was wondering if there is a way to find these spaces between two character styles with GREP, and change them to quarter spaces…
Thanks, Chuck! Recently I decided to use the less verbose h{2,} to delete multiple space… and learned with an “oops!” moment that this expression will also zap out multiple tabs. I’ve since gone back to the verbose expression when just trying to zap out extra spaces.
Is there any difference between h and s at all? I only recently realized that s also includes the tab (I had it in my head that it didn’t).
Hi Erica!
There are many differences between s (Space) and h (Horizontal whitespace)
s Matches all horizontal whitespaces, breaks (tab, right indent tab, and indent to here), and all vertical whitespaces (forced line break, carriage return and other break characters like page, frame, column breaks, …etc.).
h Matches only the horizontal whitespaces including a tab.
Therefor, it’s very wrong to use s with all cases, especially in this regex s{2,} because if there any space or more before break character, or carriage return at the end of paragraph, that will merge it with the next line.
So, the better method is using h instead of s, and p{Zs} (regular whitespaces) instead of h if we do not need including tab.