Page 1 of 1

Way to replace line breaks with spaces?

Posted: 2010 Dec 03, 10:01
by TsunamiZ
With Editor2, is there a way to automatically replace line breaks with spaces?

Such an option would be useful for reformatting text copied from Acrobat PDF files.  Because there's an issue with how text is formatted in PDF files.  To format paragraphs and text layout on a page, Acrobat resorts to inserting line breaks between sentences.  Here's an example of a copied paragraph from a PDF magazine using Acrobat's text selection tool...

Like chocolate and peanut butter,
tower defense games and zombies
were made for each other. But it
took the twisted genius of casual gaming
impresario Popcap to build
the towers out of wacky plants.

There are also no spaces at the end of each line.

Posted: 2010 Dec 03, 12:10
by Kilmatead
Use Search -> Replace to find all occurrences of '$0D' and replace them with '$20'.

Image

Keep in mind that this is a "dumb" search, in the sense that it will also replace legitimate paragraph breaks with spaces, which may not be what you want, so perhaps letting it confirm each one (instead of "Replace All") might be a better approach, depending on the number of lines you have to convert.

This could be avoided by doing three "passes" - the first to change all occurrences of '$0D$0D' (de facto two consecutive line breaks, in other words, a "true" paragraph break) with some phrase like "I_Breathe_What_You_Call_Sorrow", then do the above replace (this time selecting "All") of $0D (single) for $20, then make a third pass to reconvert all "I_Breathe_What_You_Call_Sorrow" instances back into $0D$0D.

As ed2 keeps these previous items in its drop-down menus, the multiple-pass method isn't as arduous as it seems.

Posted: 2010 Dec 04, 22:22
by TsunamiZ
thanks for the info.  how did you find out those characters?

Posted: 2010 Dec 05, 06:18
by Kilmatead
Welcome to the wonderful (?) world of hexadecimal ASCII, which once upon a time was drilled into the impressionable minds all children who dreamed of writing printer drivers, or imitating Marcel Proust, as the mood struck them.

At 13, I was regrettably unable to grow the moustache, so I memorised the ASCII table instead.  A life well wasted.

Image

Posted: 2010 Dec 05, 06:31
by nikos
there's also the special characters selection box in there

Posted: 2010 Dec 05, 06:48
by Kilmatead
Well, yes, but that only provides the EOLN, which is just not as impressive as a moustache, as all scruffy-types do know on Sunday mornings. :shrug: