Friday, April 29, 2011

Remove Trailing Whitespace Gotcha! Underline Tab Stops Disappear

As a book designer, I often design study guides. They're small little workbooks that are used in a roundtable discussion group. The workbook is designed to be written in. And of course, like every book designed to be written in, there are handy little lines on which to write. I have set up a paragraph style to format these lines. (Click on the images below to see a larger version of them.)

To format my line in InDesign, I have set up my document with a right-aligned tab stop, with an underscore leader, and then adjusted the tracking to tighten it up a bit.

Some people instead like to make underlines by creating an underlined tab (rather than a tab with an underscore leader), and then adjusting the thickness of the underline in the underline Option sections of the Paragraph Styles dialog box. Either way works fine.

But I discovered something yesterday that I feel compelled to share. I often use InDesign's built-in GREP find/change to clean up formatting. My favorites are "Multiple Return to Single Return", Multiple Space to Single Space", and "Remove Trailing Whitespace."


While wrapping up a project yesterday, I ran these GREP find-changes, clicked "OK," and then was about to scroll back through my document to give it a final look before making a PDF. But what did that dialog box just say?

Well, hang on a minute! I know that I had some extra space at the end of paragraphs, but 465 replacements seems a bit excessive. Remember how I had all those nicely formatted lines for writing on? Now they are all gone!

Apparently, InDesign's default GREP expression for "Remove Trailing Whitespace" also removes tabs at the end of a paragraph. But my tabs served a very important function: they provided the lines on which to write.

So, if you use InDesign's default "Remove Trailing Whitespace" GREP Find/Change expression, be aware that it can affect much more formatting than just the few extra spaces at the end of your paragraphs.


  1. Gah! Good catch, Kelly.

    The GREP code for white space (backslash-s) finds all things that InDesign considers a space: the regular space character and all its variations (thin space, em space etc.) as well as tabs and returns.

  2. Do you know if you can apply "remove trailing whitespaces" to a Paragraph style??

    1. Try this: create a paragraph style that applies a 1% horizontal scaling to characters. Then in your paragraph style > GREP Style > apply your 1% Character Style to this: \s+$.

      It doesn't seem to work with tabs or right indent tabs, but that should take care of other kinds of trailing white spaces.