is now part of CreativePro.com!

Delete Tab at Beginning of Paragraph and Apply a Paragraph Style

16

In a comment on another post, BT wrote:

I am revising someone’s layout. Hundreds of paragraphs were started with a tab. I want to remove the tab and apply a style that indents the first line.

This is an excellent question, because while it’s easy to search for tabs and delete them, and it’s easy to search for tabs and apply formatting to the paragraph (using the tricks in that blog post linked above), it’s not obvious how to to do both of these at the same time. And, in fact, it’s not possible in a single step using the normal Text mode of the Find Change dialog box.

You can do it in two steps: Search for a tab and apply the paragraph style, then search for tabs and delete them. But to do it in a single step, I believe you need to use the GREP tab. (Don’t worry; it’s a really easy one!)

Type this into the Find What field: ^\t(.) and type this in to the Change To field: $1

Then set the Change Format field to apply the paragraph style.

 Findindent

That GREP expression means “find a tab at the beginning of the paragraph, followed by any single character, and remember what that character is.” The change-to expression just means “put that single character back in.”

Hit Change All, and you’re good to go! If you’re going to use it regularly, remember to click the Save Query button at the top of the find/change dialog box, so you can choose it again quickly.

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Burkans says:

    In many cases it is possible in the normal Text mode of the Find Change look for a paragraph symbol followed by a tab symbol and change them with a paragraph symbol simultaneously applying paragraph style.

    • Jongware says:

      The problem with that method is that the same paragraph style gets applied to the paragraph return as well — and that is part of the PREVIOUS paragraph. David’s way ensures the new style gets only applied to the “current” paragraph.

      • Quentin says:

        Your method would also ignore single-paragraph articles and the first part of any multiple-paragraphs text bloc, since there would be no “leading” paragraph break before.

  • BT says:

    Many many thanks, David, not least for getting me into GREP which I have been avoiding. Your post also shows me how to do some other things I need to do (like having wildcard alphanumerics searched for and remembered) that are tremendously useful. The late great Kathleen Tinkel often told me you were tops, and you know what? She was right. (As usual.)

    I did think of a much less elegant way to do this while staying in standard find. You would search for tab, and replace with [section or some other character or string you knew didn’t exist anywhere else] and the new paragraph style. Then you would have to issue a separate command to delete all the dummy characters. That would work, wouldn’t it? Except that you still would not be able to search for a prior paragraph end marker. Which brings us to:

    The point raised by Jongware is critical to know, too. I had already noticed that searching for a string involving the return of the previous paragraph and doing a replace with a paragraph style would, unfortunately, change the paragraph style of the previous paragraph.

    So if you want (as I do) to search for tabs after a paragraph, (or, as you more elegantly express it, a tab at the beginning of a paragraph), yours really is the only satisfactory method.

    Again, many thanks.

  • BT says:

    David, may I, somewhat off-topic, trespass on your kindness for some more GREP advice? In fixing these paragraphs I have found many that have an additional problem.

    1. Unwittingly, the previous typesetter set all these paragraphs in Char Style X, which is 12 point Adobe Caslon Pro Italic. He then overrode by hand to set the paragraphs in 11.5 Caslon Pro Regular on 15 pt, which is the text style of the book.

    2. I want to restyle these paragraphs so that they have a proper paragraph style. I would like to get rid of Character Style X and preferably have no character style at all.

    3. Nevertheless, I need to preserve two vital elements in the text: many names set in italics, and manual endnotes, which are in the ‘Endnote Character Style.’

    I had hoped that I could short cut the problem by changing ‘Style X’ to Adobe Caslon Pro 11.5 Regular. Unfortunately, this blanks out the italics and, if I remember correctly, the Endnote style.

    This is really a mess which could take many many hours to fix by hand, since there is a lot of affected text (in a book of several hundred pages).

    Is there a way to automate the fixing of the problem?

    Many thanks,

    BT

  • Jeff says:

    Could something similar be used to replace leading spaces before a paragraph. I do a monthly newsletter and the authors space their paragraph indentsin word–against my constant protestations. To make matters worse they don’t always use the same number of spaces. Any GREP string that could handle this?

  • Katherine Lloyd says:

    I find that if I apply a paragraph style this way I lose the applied styles like ital (as if the paragraph style overrides everything). Is that usual?

    I realize the itals could all be character-styled first and that won’t happen but I wonder if I have missed something.

    Conversely, if I use a shortcut to apply paragraph styles as I go through the doc, paragraph style is applied without losing the applied styles as long as Option isn’t used with the shortcut.

    Thanks for any insight!

  • Bill says:

    Pow! Katherine’s post was very important for me to read. When you style a paragraph with a lot of additional attributes, InDesign usually keeps what you want (let’s say italic) and gets rid of everything else. I had therefore assumed that if I did the same thing using find/change, InDesign would behave similarly. As Katherine points out, it doesn’t. It clears italics. This can lead to an enormous headache. Thanks for guidance to the thread where the solution is revealed, and of course, as noted there, the Blatner Tools are also a great way to deal with this and related problems.

    On the subject of Grep and Tab/style replacement, I have a related question. I had a book of plays to revise where all the stage directions had a return before the paragraph of stage directions and a return after. Is there a way using grep that I can search for carriage return, note and remember all the text that occurs until the next carriage return, and replace with the text, terminated by a single return, and styled with a specified paragraph style? (I hope that’s clear) – – Many thanks, Bill

  • Bill: If I understand what you’re saying correctly, then yes. You could search for (?<=\r)\r(.+)\r(?=\r) and replace it with $1 and a Paragraph Style via the Change Format section.

    That would find “blank paragraph followed by anything followed by blank paragraph,” get rid of the blank paragraphs and apply the paragraph style.

  • THANK YOU! You are my hero!

  • Adriel says:

    This no longer works, still have the indent at the beginning and still the hidden character isn’t showing (hidden character is turned on).

    If you happen to have a solution, appreciated and thank you.

  • >