I often copy text from PDFs of books and articles, as well as from images, and paste the text into Scrivener or Word. I often use the app TextSniper to grab text from images and PDFs. Then when I go to paste the text into Scrivener or Word, the text often has a carriage return after every line, like this (I inserted the ¶ symbol after each line below for clarity):
The latest draft, which is broadly similar to one released¶
on Friday, called on nations to return next year, instead¶
of 2025, with stronger pledges to cut planet-warming¶
emissions in this decade. It urged wealthy nations to “at¶
least double” by 2025 the financial aid that they provide to¶
developing countries to help them adapt to heat waves,¶
floods, droughts and wildfires.¶
To get rid of the carriage returns after each line, I have to scroll up from the end of the pasted text, highlighting all of the pasted text, then press my keyboard shortcut (F4) to trigger TextSoap to remove the extra returns.
It's a pain to have to scroll up from the end of the pasted text to highlight the text. I want to create a macro that will highight the text I just pasted (by selecting the text from the end of the just pasted text to the beginning, where my cursor originally was when I pressed CMD-OPT-V), then the macro will trigger the TextSoap shortcut (F4) to remove the extra returns.
I'm new to KM and am not a programmer. Any ideas? Thanks!
There's no great way to do that on demand in any generic application. Many people want it to be so, but it's not – because neither the macOS or most apps have the capability to know what the selection is in a text editing context.
Usually the best you can do is preprocess your text before pasting it.
BBEdit has a paste-and-select command that selects what you just pasted. You could ask the Scrivener developer for such a feature.
On the other hand – since Scrivener's find capability is not bad, and Keyboard Maestro can set the find pasteboard there's a sneaky way to do this.
It won't work in Word, although there's a possibility that you could use AppleScript to do something similar.
Based on your description, it doesn't sound like you need to copy the text again after it's been pasted, or even to run it through TextSoap. When OCRing text with TextSniper, you can just turn off the option to keep line breaks:
And for text copied from other sources, you can use KM to remove the link breaks from the clipboard:
I tried the macro which filters the clipboard like Gabe suggested--the macro works in Word, but not in Scrivener. All I did was add Scrivener as an additional triggering application. When I paste the text into Scrivener, it still has the returns after every line:
The latest draft, which is broadly similar to one released¶
on Friday, called on nations to return next year, instead¶
of 2025, with stronger pledges to cut planet-warming¶
emissions in this decade. It urged wealthy nations to “at¶
least double” by 2025 the financial aid that they provide to¶
developing countries to help them adapt to heat waves,¶
floods, droughts and wildfires.¶
Not sure why Scrivener is working differently than Word.
I think I figured this out. The carriage returns are stripped when pasting some paragraphs from the PDF, but not when pasting others from the same PDF. I used ABBYY FineReader to OCR the PDF. The odd behavior is probably from using FineReader. If anyone has a suggestion on how to fix this, I'd love to hear.
I figured it out. I had scanned a book, and on some of the 2-page spreads, the inside margins of the 2 pages was really close together because the book binding was messed up, which I think confused ABBYY Fine Reader: