Way to replace line breaks with spaces?

Questions & Answers

Moderators: fgagnon, nikos, Site Mods

Post Reply
TsunamiZ
Gold Member
Gold Member
Posts: 597
Joined: 2005 Nov 06, 04:44

Way to replace line breaks with spaces?

Post 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.
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post 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.
TsunamiZ
Gold Member
Gold Member
Posts: 597
Joined: 2005 Nov 06, 04:44

Post by TsunamiZ »

thanks for the info.  how did you find out those characters?
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post 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
User avatar
nikos
Site Admin
Site Admin
Posts: 15760
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

there's also the special characters selection box in there
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post 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:
Post Reply