How to delete space at the start of every paragraph?
Learn / Forums / General InDesign Topics / How to delete space at the start of every paragraph?
- This topic has 7 replies, 5 voices, and was last updated 8 years, 2 months ago by Deborah Hands.
-
AuthorPosts
-
-
November 21, 2014 at 9:40 am #71767Andy McgroartyMember
Hi there
I wondered if you guys might be able to help? I have received a book to typeset from a client and each paragraph has a space before the text starts. See the following image: https://postimg.org/image/vnr80e751/
I know it is slightly pedantic, but is there any way that i can remove all of these in the document? I thought about find/change but wasn’t sure how to do it?
Any suggestions would be most appreciated.
Thank you
-
November 21, 2014 at 10:07 am #71769David BlatnerKeymaster
You could do a grep find/change and search for
^\s+?(.)
and replace with$1
That will delete one or more spaces at the beginning of any paragraph.-
November 22, 2014 at 2:04 am #71791Andy McgroartyMember
Thank you David, I will try that. But do you have any links on how to go about that, or what greps are? I have seen it mentioned a lot but don’t really know what they are.
Thanks and best wishes
-
November 22, 2014 at 4:32 pm #71795Theunis De JongMember
Andy,
Go to the regular Find/Change panel and then click the GREP tab — not the usual “Text” tab. Make sure both Find and Change text fields are empty, and there is no formatting in either. Those work the same as it does as in the regular Text change.
Type in the top (“Find”) field
^ +
— mind the gap! That is a single space in-between. Leave the bottom “Change” field blank. Now hit “Find” and check if it finds and highlights the first occurrence of a space at the start of a paragraph. If it does, hit “Change all” and duck.
The magic codes are
^ = Start of Paragraph. Sort of the same as “^p” in the regular Find/Change dialog, except that this is a *position* only, and it doesn’t ‘eat’ the paragraph return. Since it’s only a position and not an actual character, it also works when there is no Paragraph return ‘before’ the start of a paragraph.
(imagine a single space here) = The literal text to find. GREP uses lots and lots of special characters as commands (the ^ above is one of them) but a space is just a space.
+ = The previous command, group, or character, and then repeated as much as possible.So this will look for *any* positive number of spaces at the start of a paragraph, be it 1 or 42 or any other number larger than 0. Replacing them with ‘nothing’ does exactly that: it deletes them.
How is this different from David’s suggestion? (Sorry David!) He suggests
^\s+?
where the ‘\s’ command stands for ‘any kind of space’. That can be useful because apart from a single regular space, this also includes tabs, hard (unbreakable) spaces, and even en and em spaces; but *also* the hard return and the soft return. The latter may unintended wreak havoc on your document, as two consecutive hard returns are *also* seen as “start of a paragraph” (right after the first hard return) followed by “white space” — the next hard return. The next hard returns — any number of them — will also disappear!
Based on your image I understand there are only regular spaces at the start of paragraphs, and so my search expression is a bit safer.
For more information: IDSecrets has a page full of links to resources on GREP: https://creativepro.com/resources/grep
-
November 24, 2014 at 4:03 am #71815Andy McgroartyMember
Thank you Mr Jong!
That worked a treat!
And thank you for your explanation and links, they are very useful!
Best wishes
-
-
November 21, 2014 at 6:01 pm #71787Dwayne HarrisMember
Andy
Did they give you a word file to import or was it already in InDesign?
I find it much easier and problem-free to tweak the Word file before importing.
-
November 22, 2014 at 2:10 am #71792Andy McgroartyMember
Thanks dwayne. When I think about it, I was sent a pdf and I must have converted it to word. But I am half way through the iD document now and only just noticed, so it would be counter productive to go back to the original.
But thanks again for your help, always appreciated.
Best wishes
-
-
December 17, 2015 at 8:15 am #80266Deborah HandsMember
Thank you for this!! I have a client who regularly uses spaces instead of tabs, and just worked on a doc from a different client with one space in front of almost every paragraph. I hope everyone knows you can save GREP queries. Hopefully they don’t go away with version updates!
-
-
AuthorPosts
- You must be logged in to reply to this topic.