5 Replies Latest reply on Feb 4, 2012 10:18 AM by Peter Spier

    White space, begone!

    LouWrench Level 1

      In GREP we have a "Remove trailing white space" option. Is there anything for leading white spaces? I can search for paragraph return followed by space and replace with para return, but I am afraid of changing  the para formatting!

      Also that damned space befor punctuation, parenthesis, before tabs etc.

      Is there asa library where people can speak fluent GREPanese store some of their useful stuff. This is one of those "I am too busy to learn how to save time" situations!

      Lou

        • 1. Re: White space, begone!
          [Jongware] Most Valuable Participant

          This GREP search will find regular spaces, unbreakable spaces, and tabs -- these are the kinds that you might find in an imported document. Replace with nothing to get rid of 'em all. Be Warned that authors mis-use tabs and spaces all the time, for instance, to indent a new paragraph (use First Line Indent for that), or to format tables with (use Tables for that), or to manually attempt to align a sequence of numbers (use any ol' trick for that EXCEPT tabs or spaces).

           

          ^[ \t~S]+
          

           

          The meaning of all this: locate Start of Paragraph, then find any sequence of Space, Tab, or Fixed Space, ad inifitum.

           

          Using the Start of Paragraph marker instead of your suggestion "paragraph return" ensures the previous paragraph won't be touched (which, as you found, messes up the assigned styles because this hard return belongs to the preceding paragraph).

          • 2. Re: White space, begone!
            Peter Spier Most Valuable Participant (Moderator)

            Jongware,

             

            Why use the class instead of just ^\s+ for this? Does \s miss something, or find something it shouldn't?

             

            Lou,

             

            Have you tried running the Find/Change By List script that is installed inthe samples? It fixes almost all of this stuff execpt the last extra blank paragraph in a Word file.

            • 3. Re: White space, begone!
              [Jongware] Most Valuable Participant

              Peter, \s includes regular space, tabs, fixed spaces (both kinds), and also Thin, En, Em, Number, Punctuation spaces (which, typically, one would manually insert in ID and so probably would not need deleting) but also the paragraph return and the soft line break. So if you use "^\s+" you would remove all multiple hard returns as well, and while at times this might be useful, usually you wouldn't want to do that willy-nilly.

               

              If you check the standard "Double Space to Single Space" GREP query [*], you can see that Adobe circumvented this by making a rather extensive list of all possible white space characters except for the Paragraph Return and Soft Line Break.

               

              (To include all possible white space except for returns and line breaks you can write, somewhat shorter,

               

              ^((?![\r\n])\s)+

               

              but perhaps the character set notation [..list of codes to find..] is easier for beginners to grasp.)

               

              [*] The standard "Remove Trailing Whitespace" query removes all double hard returns as well.

              • 4. Re: White space, begone!
                LouWrench Level 1

                Thanks guys,

                I guess I missed that there was a GREP for "start of paragraph" That solves the problem! Search start para space then replace with nothing.

                Lou

                • 5. Re: White space, begone!
                  Peter Spier Most Valuable Participant (Moderator)

                  Thanks Jongware,

                   

                  I suspected that was the answer. I, of course, think that empty paragraphs should be banished in favor of proper spacing so that wouldn't bother me, but I'm sure not everyone would agree. The Find/Change by list scritp removes them, too.