August 27 2007 • 5:48 PM

Removing the Paragraph Return at the End of Story

I don’t like to have extra stuff floating around my InDesign documents. For example, I don’t like to have blank, empty frames sitting around — I always take the time to delete them. Similarly, I like to remove the blank carriage return at the end of text frames so that the story ends without an extra return. There’s no pressing reason why you need to do this. In fact, if there’s a chance that the frame will someday be threaded together with another frame, you probably do want the extra return there (or else you’ll get the last paragraph of one frame merged with the first paragraph of another frame).

However, let’s say you want to remove those extra returns. (That’s one of the email requests I received this morning.) How to do it? In CS2, you’re probably stuck with manually clicking and deleting. Perhaps someone has a script that will do it.

But in CS3, you can use GREP. Open the Find/Change dialog box (Command/Ctrl-F), switch to the GREP tab (press Command/Ctrl-2), make sure the Search pop-up menu is set to Document, and type this in the Find What field: \s+\Z

Leave the Change To field blank and then click Change All. InDesign should remove the blank return at the end of every story in your document.

This appears to work because of a hidden, undocumented code: backslash-Z appears to mean “at the end of story.” So this GREP code says “find one or more spaces at the end of the story.” Note that \A seems to mean “at the beginning of the story,” so if you want to remove extra white space at the beginning of the story, you’d type \A\s+

Thanks to Gerald Singelmann who pointed out on the Adobe forums that someone told this trick to him, but he can’t remember who. Sounds very mysterious to me!

Warning: I don’t guarantee that these kinds of undocumented tricks will work; save your document before running large GREP searches, proof your work afterward to make sure it didn’t mess anything up.

18 Responses discussing this post. Add yours below.

  1. Jabed Imtyas
    August 27th, 2007 • 8:06 pm • Link

    Thanks David, Your are a life saver, I’ve tested it and works with out breaking any sweat. I’ve been looking for a solution for this problem for quite some time. Thanks to your post it will save some time & pain from now on. Hopefully this post will help others who have been going through the struggle as i did. Load of thanks

  2. low Jackson
    August 28th, 2007 • 7:19 am • Link

    Cool, another one for the tidy freaks!

  3. me
    August 28th, 2007 • 8:09 am • Link

    you can also just do a search and replace on ^p^p and replace with ^p and that’ll pull out all extra paragraph spaces. you shouldn’t have them within your text anyway if properly formated.

  4. Eugene Tyson
    August 28th, 2007 • 10:45 am • Link

    I have worked with old comps who told me all about the teletypewriter, baudot code, linotype, et al printing machines along with RRTY, ITA2 (used by Western Union I believe).

    One printing machine was just a big strip of punched card with a pattern of holes throughout.

    In those days there weren’t any such thing as a space before and after. The carriage return was the only way to seperate paragraphs of text.

    Sadly those days are not long gone. Computers and Typesetting/Designing applications are relatively new in terms of printing, albeit a revolutionary introduction.

    Because the olden days of printing are not really that old there are old comps who have moved onto typesetting on a computer. All they have is a keyboard and a page and they don’t know about all the other things they can do regards paragraph and character attributes they can apply.

    All they need to know is, Type Size, Font and Leading and they are ready to do their job.

    So not everyone knows how to set properly regards today’s methods. And so there are some people who still like to put in a carriage return instead of space before and after.

    With this in mind, the above method is a perfect way to remove extra spaces and not only that any other thing you might have at the end of documents that you don’t want.

  5. August 28th, 2007 • 2:45 pm • Link

    David, couldn’t you just hit Ctrl or Command-Z? If a GREP Find/Change doesn’t quite do what it is supposed to do? All the changes should be undone in one hit afaik (maybe I’m wrong?).

  6. David Blatner
    August 28th, 2007 • 3:56 pm • Link

    Cari, hey! What are you doing here? Aren’t you supposed to be prepping for The InDesign Conference in Melbourne tomorrow? ;)

    Yes, you are absolutely correct: If something goes wrong with the find/change, you should be able to Undo it. But to be honest, I trust Revert more than Undo for something like this. Just superstitious.

  7. Eugene Tyson
    August 28th, 2007 • 4:20 pm • Link

    A couple of times I’ve tried some custom GREPS and InDesign just quits.

  8. David Blatner
    August 28th, 2007 • 8:29 pm • Link

    I’m sitting here with Olav Martin Kvern, and he says (about this GREP trick), “Oh, I’ve known about that for a while.” Then he throws out a bonus trick: You can use the same trick to add a bullet at the end of all your stories:

    Search for (.\Z) and replace with $1• (or whatever bullet character you want).

    Note that at first glance there doesn’t appear to be any difference between uppercase and lowercase Z. Let me know if anyone finds a difference.

  9. August 29th, 2007 • 1:11 am • Link

    Oh that Ole! ;-)

    One of you should add the Z thing to the Live Help GREP page.

  10. Klaus Nordby
    August 29th, 2007 • 10:37 pm • Link

    Thank you, David! Throughout the years I have manually deleted hordes of those pesky end-of-story CRs, but now I finally have the magic bullet solution — duly saved as a GREP preset.

  11. August 30th, 2007 • 2:27 am • Link

    Just watch out if the last character in your story is an inline or anchored frame. That GREP of Ole’s will do a real nasty — the frame disappears but the story editor shows the anchor as still there.

    Dave

  12. Alex
    August 26th, 2008 • 4:16 pm • Link

    is this where the tidy freaks rejoice?

    yippee!

  13. June 3rd, 2009 • 8:33 am • Link

    How would one go about adding something to the end of a story? I need to add ” (NIV)” to the end of every story with the “!Reference” paragraph style.

    I set the GREP to…
    Find What: \Z
    Change To: (NIV)
    Search: Document
    Find Format: Paragraph Style: !Reference

    When I click the Find Button my text cursor goes to the end of a story. When I click the Change button, nothing happens.

  14. David Blatner
    June 3rd, 2009 • 8:57 am • Link

    @Syl: I believe you need to find an actual character. For example, search for .\Z (dot backslash Z) and then replace with $0(NIV)
    The $0 is grep for “whatever you found” (in this case, the last character of the story.

  15. June 3rd, 2009 • 10:06 am • Link

    @David: Thank you. Your suggestion worked. Knowing about $0 helped me. I was able to search for the any digit wildcard followed by \Z and replace with $0 (NIV). Thank you for your help.

  16. GregB
    December 6th, 2009 • 7:46 pm • Link

    Go the tidy freaks.

    When will I get time to do work, when I find all these great tips.

    @Cari: Go the Aussies

  17. Leah
    December 10th, 2009 • 6:46 pm • Link

    Thank you, thank you, thank you!!!

    This is very important if you have text in a table. The extra paragraph makes the whole box longer. And you can’t replace ^p^p with ^p in some instances because the hash symbol is at the end, causing its own paragraph without being a paragraph symbol.

  18. Liz
    December 22nd, 2009 • 11:49 am • Link

    This works great in the InDesign CS3 Find and Replace dialog box…but I am trying to use it in a javascript and it gets ignored. Anyone have any insight?

Subscribe to the Discussion

Get the ongoing discussion surrounding "Removing the Paragraph Return at the End of Story" delivered to you. Click here to subscribe via RSS.

Leave a Reply

You can use limited HTML tags, such as <em></em> for emphasis/italics and <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

InDesignSecrets reserves the right to edit and/or remove posts and comments.