Need training at your office? Request a quote for custom training.
Adobe InDesign: Removing Unwanted Spaces, Fast!
By Barb Binder, Adobe Certified Instructor on InDesign
Updated April 22, 2016
Too many extra spaces in your InDesign documents? No problem. You can quickly and (painlessly) remove extra spaces by running one or more Find/Change queries. The three I am going to show you are using GREP, which uses patterns instead of actual character strings to locate and fix issues in InDesign documents.
- Place all your files into the InDesign document. (I place stories on the Pasteboard when I’m not ready to place them on the actual pages.)
- Choose Type > Show Hidden Characters so that you can see the non-printing characters.
- Chose Edit > Find/Change.
- Drop down the Query list on the top line and run each of these queries with the Search parameter set to Document (to search all the stories in the InDesign document):
- Multiple Space to Single Space. Instead of running a series of searches to weed out all extra spaces, just pick this one preset. The Find What line looks a little scary, so just don’t look too closely. If you simply can’t look away, understand that it’s a string of GREP characters that looks for two or more spaces (i.e., em spaces, en spaces, flush spaces, hairspaces, etc.) and replaces all of those with one spacebar space. Hit Change All and poof! All extra spaces are gone.
- Multiple Returns to Single Return. Another preset, this one pulls out all two or more hard returns and replaces with one.
- Remove Trailing Whitespace. Trailing whitespace refers to one or more spaces, tabs or extra returns at the end of a paragraph, between the final punctuation and the hard return(s). When it’s just a single space, most of the time they don’t cause any problems, but sometimes they won’t fit on the same line as the punctuation and they force a new line or even a new page. For long documents, this can be a real nightmare. This query also picks up the double returns and even multiple spaces (but only when the spaces are at the end of a paragraph) so I tend to run this one first.
- Multiple Space to Single Space. Instead of running a series of searches to weed out all extra spaces, just pick this one preset. The Find What line looks a little scary, so just don’t look too closely. If you simply can’t look away, understand that it’s a string of GREP characters that looks for two or more spaces (i.e., em spaces, en spaces, flush spaces, hairspaces, etc.) and replaces all of those with one spacebar space. Hit Change All and poof! All extra spaces are gone.
For more information and a list of GREP characters, see InDesign Help / Find/Change.
Hello,
To complete this interesting post, we can remove unwanted spaces between double characteres as parenthesis, braces, brackets, etc. with a lookbehind and a lookahead :
(?<=[([{])s+|s+(?=[])}])
In this example, the lookbehind (?<=) looks, in a character class [ ], for an open parenthesis or an open bracket or an open brace followed by one or more spaces. The lookahead (?=) looks for closes characteres preceded by one or more spaces.
@Laurent Tournier
Thank you for sharing, Laurent.
Why did you not post the text string from the first Grep example?
Hi Mrolfer: the GREP strings in all three examples are shown as screen shots under the instructions. If you can’t see them for some reason, you can access all three by opening up the Find/change dialog box in InDesign CS3 or CS4. ~Barb
WOW, what a relief to find such a piece of information while you ere desperately looking for it!
Thanks Barb
So glad it helped, Abdul!
~Barb
So, so helpful. Thank you!
Seriously, how awesome is this! Thanks heaps, clicking a button once is soooo much better than clicking a button 450 times.
This is really useful – thanks 🙂
Very helpful. Thanks for sharing.
Barb! Thanks alot it really works 🙂
Thanks a million! Worked like a charm.
Thanx 🙂
Is it possible to find all “tabs” and replace with no space? Actually more specifically, I have two tabs in each line of text. The first tab I would like to replace with no space. The second tab I would like to replace with one space.
I really appreciate anyone’s incredible knowledge if you have a solution for this as my document has 10751 tabs. 😮
Hi Donetta:
How about searching for two consecutive tabs, and replacing with a single space? Here’s how to set it up in InDesign:
Find what: ^t^t
Change to: (press the spacebar once)
~Barb
Thank you Barb.
That ^t^t was just what i needed.
😉
THANK YOU SO MUCH!!!! This saved me so much time! I am forever grateful!
Love this really, really helpful thanks so much!
I have a question though. Almost ever time I receive a manuscript from a client, they seem to have manually indented their paragraphs by adding a couple of spaces at the beginning of each one. Is there any quick and simple way to remove these? That way I can use paragraph styles for proper and consistent indentation.
Excellent point, Antony. InDesign has a query for removing trailing whitespace, but not leading whitespace.
There are several ways to do this. Here are two easy ones:
After you run the “Multiple Space to Single Space” query, create one additional text query:
Find what: ^p(press the spacebar once)
Change to: ^p
This will find the one remaining space at the beginning of a paragraph, and will replace it with a hard return.
Or, you can just create a GREP query:
Find what: $s+
Change to: r
In either case, save the query as “Remove Leading Whitespace” so that you can just run it in the future.
~Barb
Thanks, thanks, thanks!! thanks a lot! you saved my night!
Thank you, you saved my life!
I have been in despair with customer’s word documents. Instructions on hard returns and soft returns met with blank incomprehension and still I receive files that almost bring me to tears. Line after line of deleting spaces – on and on.
Your grep instruction has been such a godsend to me, I don’t know how I found myself on your site, but if you ever brought out a grep app I would pay good money for it. Thank you so much. I can now say “bring it on…bring on your awful word docs”
BTW have you got any instructions for removing the spaces in lines, when the customer doesn’t know how to tab, so does space-space-space-space?
Hi Elizabeth:
If the typists are randomly adding the extra spaces mid-paragraph, use the Multiple Space to Single Space GREP query. If they are using spaces between columns that should be tabbed, then search for multiple spaces, and replace with a tab. Cycle back and replace multiple tabs with a single tab. But that’s going to require that you look at each table closely as you update, as the chances for problems are much greater than within paragraphs. Here’s a spot where I’d step in and try to help them prepare the tables correctly before turning them over to me. Good luck!
~Barb
Hello,
I have one problem in indesign paragraph related. When i add new formatting like bold/color in some words, it add leading some blank characters. so extra spaces add in new bold/ color words. How can i remove it.
Thanks in advance.
You will need to turn off auto-leading and used a fixed value.
thanks SO much. your directions were clear and easy to follow AND you saved me a TON of time!
Great information, many thanks!
Thank you very much for this really helpful information, Barb!
I have been formatting a 400+ page book that I have written and I am sending it to the printer next week. I have struggled with a number of these issues as I originally wrote the book in Word. I ran the Remove Trailing Whitespace GREP and after I did it, InDesign would no longer output to PDF. It turns out that something corrupted one of my tables when I ran the GREP and clicked change all. I began to output the document several pages at a time and located two offending pages. I was able to rebuild the tables and everything is great now.
I just did the Remove Leading Whitespace and Parenthetical White Space and did the changes manually and it worked awesome!
I finished writing the book in April and it has taken me until November to get it all edited and formatted and create the images and cover. I never dreamed that this part of the process would be so time intensive!!!
I am a dentist and a part time writer and I have come to realize that you professional folks are worth your weight in gold!
Thanks so much for taking the time to share these tidbits, they are a Godsend!!
I design books and often the authors put a tab at the beginning of their paragraphs. I need to removed them using GREP but don’t remember how. Can you help?
You don’t need GREP for that. Just do a regular text Find/Change:
Find: ^p^t
Change: ^p
This tells InDesign to search for any tab character following a ¶, remove the tab and leave the ¶.
Thank you! 🙂
Thank you so much! You helped me a lot!
THANK YOU!!! You just saved me days – literally – DAYS on this annual project!
How to remove extra spaces at beginning of a paragraph please? thank you!
Hi Cade:
Choose Edit > Find/Change
Choose the GREP tab at the top of the dialog box
Find: ^\s
Change: [leave blank]
~Barb
This works! Thank you so much!
Thanks, been thinking I needed to create a GREP for this but clearly this was there the whole time. Saves from doing the old-fashioned find and replace.
THANK YOU!
Life saver, I tell my copy guy not to double space anymore your not using a typewriter. But old habits are hard to break. Thank you so much this is so awesome.
I tried to do this with non breaking spaces and it just did it with one- not the whole document?
what am i doing wrong 🙁
Hi Elmer:
Set the search to Document and try again.
~Barb