Copy And Paste Without Linebreaks

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: Tracker Support, TrackerSupp-Daniel, Sean - Tracker, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
brody-xr3
User
Posts: 143
Joined: Wed Jan 22, 2020 12:27 pm

Copy And Paste Without Linebreaks

Post by brody-xr3 »

Hi,

Having followed this thread - 34,000+ views - for a long time before buying the program - yay! :D

viewtopic.php?f=62&t=22846&hilit=tags+s ... 50#p132887

I can tell that the ideas described therein will be a long time in the making.

Feel disappointed as, from the discussion, while though it seems the primary market for the product is business and engineering - I'm still struck by what use Peter28 - memberlist.php?mode=viewprofile&u=103296 wrote five years after his original post:

The problem I have is to remember all what I read and make it quickly accessible for future reference. When I read a book in the past, I made (handwritten) notes, which is a lot of (copy down) work.


Somehow, to me, the market share represented by people who need to remember what they've read seems...as large, if not larger. I, like Peter, am in that same group.

Looking at the thread I can tell that this is a HUGE undertaking as the advocates - myself included - have got it envisioned. Currently I don't have the technical background to write a working plugin.

However, I have an idea that could take LOTS of folks a lot closer along the way to having pdfx get out of its own way along that road to helping folks remember what they've read. Tell me what you think. Please can you add a feature that pastes text without line breaks?

For example, if I have a long quote I want to recall and need to port over to a flashcard system or any other means of recalling, right now for Copy & Paste I'd get:

The subject of this Essay is not the so-called Liberty of the Will, so unfortunately
opposed to the misnamed doctrine of Philosophical Necessity; but Civil, or Social
Liberty: the nature and limits of the power which can be legitimately exercised by
society over the individual. A question seldom stated, and hardly ever discussed, in
general terms, but which profoundly influences the practical controversies of the age
by its latent presence, and is likely soon to make itself recognised as the vital question
of the future. It is so far from being new, that in a certain sense, it has divided
mankind, almost from the remotest ages; but in the stage of progress into which the
other states and societies now find themselves, it presents itself under
new conditions, and requires a different and more fundamental treatment.

Instead of:

The subject of this Essay is not the so-called Liberty of the Will, so unfortunately opposed to the misnamed doctrine of Philosophical Necessity; but Civil, or Social Liberty: the nature and limits of the power which can be legitimately exercised by society over the individual. A question seldom stated, and hardly ever discussed, in general terms, but which profoundly influences the practical controversies of the age by its latent presence, and is likely soon to make itself recognised as the vital question of the future. It is so far from being new, that in a certain sense, it has divided mankind, almost from the remotest ages; but in the stage of progress into which the other states and societies now find themselves, it presents itself under new conditions, and requires a different and more fundamental treatment.

And, I'd be obliged to go through the text and manually - or in the case of Sumnotes, for a fee - have the seven linebreaks removed.

Now, if I was fortunate enough to try to give Plato's Republic another go...that clocks in a 454 pages, small font.

I'll find lots of GREAT quotes I may just want to grab at the moment...and...each time I'll need to...

copy-paste-excise linebreaks

Sure! I can go to word and run search and replace! But...after about the 25th time...that get's counter-productive to the thinking I need to do.

The same with exporting comments...exporting comments without linebreaks would be a BIG step forward - though I've found workaround - basically exporting to excel and then through a bulk search and replace and... LOTS of steps. All based around the idea that...I need to get the linebreaks out of the things I've highlighted in order to be able to use them.

I've got it down to a fair science! But, it often falls to pieces when...I need just a wee few copy pastes. And...then I'm back to:

copy-from pdfx
paste in word
bulk find and replace
open third destination file
close word or..leave it open?

Keep reading.

copy-from pdfx
paste in word
bulk find and replace
open third destination file
close word or..leave it open?

Keep reading...

So, I encourage a copy and paste feature that removes all linebreaks in the paste.

If, in doing this, it could be easily achieved for a Export Comments without line breaks, even better!

Here's what I'm using pdfx for - reading and remembering. And, whether it's Plato's Republic (454 pages) or The 7 Habits of Highly Effective People (432)...there's LOTS I'd like to be able to recall at my fingertips.

I can accept that, for the time being, pdfx wont be delivering the fingertips part via tagging. It's a big ask!

But, REALLY encourage you to add in the cut and paste without line breaks (and summarize comments without line breaks). It would be a HUGE step forward to helping me learn the things I do not yet know, or may have forgotten.

How does that sound?

BXR
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1187
Joined: Mon Jan 15, 2018 9:01 am

Re: Copy And Paste Without Linebreaks

Post by Dimitar - Tracker Supp »

Hello Brody,

Thank you for a detailed explanation of your request.

Since you have taken the time to show us how important this is to you, we on our side should pay close attention to this.

It sounds like something useful indeed.

Our developers are currently working on similar options so it won't be long until you have what you need.

As far as I understand the first request, as a workaround, you can also use some kind of Clipboard Monitor tool, that's at least until we are ready with the implementation.


Regards.
brody-xr3
User
Posts: 143
Joined: Wed Jan 22, 2020 12:27 pm

Re: Copy And Paste Without Linebreaks

Post by brody-xr3 »

:D :D :D

When I read your reply I felt grateful. Thanks, Dimitar!

Sincerely,

BXR
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1187
Joined: Mon Jan 15, 2018 9:01 am

Re: Copy And Paste Without Linebreaks

Post by Dimitar - Tracker Supp »

You are welcome Brody.

I hope that we never have to disappoint you again.
David.P
User
Posts: 1238
Joined: Thu Feb 28, 2008 8:16 pm

Re: Copy And Paste Without Linebreaks

Post by David.P »

Hi all,

I was only going to add that I wrote a Word macro for this years ago. While, after the long time, I wouldn't be able to spontaneously explain why the macro works exactly like this, it has worked tens of thousands of times for me, so it's probably a pretty stable approach, which programmatically maybe also could be used for a respective function within PDF-XChange Editor.

I remember that one of the challenges was to differentiate between hyphenation-hyphens at the end of a line (which you'd want to remove) and intended hyphens between words at the end of a line (which you'd want to keep). Similarly, you don't want to remove all paragraph marks/line breaks but only the ones within a paragraph.

The macro seems to do both of these things quite reliably, even on PDF text that has been created by OCR.

Hth & Cheers
David

Code: Select all

Sub Clean_Copied_PDF_Text ()
'
' Clean_Copied_PDF_Text
' Macro recorded on 08.07.2014 by David
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "-^p" ' Remove normal hyphens from PDF
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "­^p" ' Remove funny hyphens from PDF
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " )" ' Remove blank before closing parenthesis
        .Replacement.Text = ")"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "( " ' Remove blank after opening parenthesis
        .Replacement.Text = "("
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " ^p" ' Remove blank before paragraph mark
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
With Selection.Find
        .Text = "^p " ' Remove blank after paragraph mark
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ".^p" ' Make period before paragraph mark BOLD
        .Replacement.Text = ".^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ":^p" ' Make colon before paragraph mark BOLD
        .Replacement.Text = ":^l" ' Replace with manual line break
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ";^p" ' Make semicolon before paragraph mark BOLD
        .Replacement.Text = ";^l" ' Replace with manual line break
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
      
Selection.Find.ClearFormatting
    Selection.Find.Font.Bold = False
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p" ' Replace non-bold paragraph mark with space
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Font.Bold = True
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = False
    With Selection.Find
        .Text = "" ' Un-bold things that are BOLD
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "  " ' Remove duplicate spaces
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll ' Do it four times
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " ^p" ' Remove blank before paragraph mark
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p " ' Remove blank after paragraph mark
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " ." ' remove blank before period
        .Replacement.Text = "."
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " :" ' Remove blank before colon
        .Replacement.Text = ":"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " ;" ' Remove blank before semicolon 
        .Replacement.Text = ";"
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub
--
Edit: attached Word file with macro text because the hyphen in the line "Remove funny hyphens from PDF" would not be shown correctly in the above text box
Word Macro for Cleaning Text copied from PDF.zip
(26.52 KiB) Downloaded 38 times
Last edited by David.P on Wed Apr 01, 2020 10:03 am, edited 1 time in total.
David.P
PDF-XChange Pro
brody-xr3
User
Posts: 143
Joined: Wed Jan 22, 2020 12:27 pm

Re: Copy And Paste Without Linebreaks

Post by brody-xr3 »

Hi Dimitar & David,

I'll TELL ya, Dimitar - the replies in the thread I referenced always cheered my heart, because I could see that the Super Team you have can feel what COULD be done. Though it was always a matter of time. Seems like the time is approaching! I'll bet it's going to be QUITE cool! :D

David! Wow! That looks like a useful Macro! I went ahead and tried to get going with a Keyboard Monitoring tool but...WOW! They are COMPLEX! No easy out of the box solutions. Like buying a new phone just to get one to workl! So, this Macro will be handy.

Thanks for that!! :D

Sincerely,

BXR
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1187
Joined: Mon Jan 15, 2018 9:01 am

Re: Copy And Paste Without Linebreaks

Post by Dimitar - Tracker Supp »

:-)
igorlima
User
Posts: 138
Joined: Sat Aug 22, 2020 12:16 pm

Re: Copy And Paste Without Linebreaks

Post by igorlima »

Hi, all!

I'd really like to be able to copy and paste text from pdfs opened in xchange and paste directly into another program without line breaks where it should be spaces instead.

I understand that this is not something easy to implement, specially when trying to differentiate real line breaks from spaces, but could some tell me the situation of this feature request, please?

thank you!
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 5978
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy And Paste Without Linebreaks

Post by TrackerSupp-Daniel »

Hello, igorlima

If im not mistaken, the options here were added to help with this situation, and should, when customized to your needs, allow you to copy the content as desired:
image.png
Please let me know if changing the options in this section still do not result in the content copy you are looking for.

Kind regards,
Daniel McIntyre - Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
igorlima
User
Posts: 138
Joined: Sat Aug 22, 2020 12:16 pm

Re: Copy And Paste Without Linebreaks

Post by igorlima »

TrackerSupp-Daniel wrote: Mon May 16, 2022 5:28 pm Hello, igorlima

If im not mistaken, the options here were added to help with this situation, and should, when customized to your needs, allow you to copy the content as desired:
image.png
Please let me know if changing the options in this section still do not result in the content copy you are looking for.

Kind regards,
Hi, Daniel!

Those options indeed help with this situation. Thank you for this!

However in some lines sometimes it doesn't work. The paragraphs still show instead of just a space:

GIF.gif

I attached the pdf showed in the gif. In the gif, the content copied should be only one paragraph.

Thank you for the support!

test.pdf
(120.03 KiB) Downloaded 4 times
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 5978
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy And Paste Without Linebreaks

Post by TrackerSupp-Daniel »

Hello, igorlima

This appears to be working properly, there truly is a physical line break (Enter, Return character, or whatever we wish to call it these days) in that location. If you navigate to the area where that is, delete it, and replace it with a space character, before copying, the pasted text does not retain that same carriage return.

For clarity, the system we have here is not intended to remove existing line breaks, it simply prevents additional line breaks form being added where there normally are none.

Kind regards,
Daniel McIntyre - Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Timur Born
User
Posts: 831
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy And Paste Without Linebreaks

Post by Timur Born »

The following Autohotkey script pastes clipboard content without breaks. It should not be needed with the aforementioned Editor option anymore, but I used it before said option was added. The script is more aggressive than Editor in that it keeps paragraphs, but it does not seem to keep (certain?) headlines.

Code: Select all

; Note for following code that `r`n = newline

;Code the paragraph breaks with a special combinations
StringReplace Clipboard, Clipboard, .`r`n, -.-, All
StringReplace Clipboard, Clipboard, ?`r`n, -?-, All
StringReplace Clipboard, Clipboard, !`r`n, -!-, All
StringReplace Clipboard, Clipboard, :`r`n, -:-, All
;StringReplace Clipboard, Clipboard, `r`n`r`n, -*-, All

;Remove a dash followed by newline, since that's probably a single word across a linebreak
StringReplace Clipboard, Clipboard, -`r`n, , All

;Replace a single newline with a space
;StringReplace Clipboard, Clipboard, %A_Space% `r`n, %A_Space%, All
;StringReplace Clipboard, Clipboard, `r`n, %A_Space%, All

;Replace multiple adjacent spaces with a single one
Clipboard := RegExReplace(Clipboard, "\s+" , " ")

;Replace the paragraph break codes with newlines
StringReplace Clipboard, Clipboard, -.-, .`r`n, All
StringReplace Clipboard, Clipboard, -?-, ?`r`n, All
StringReplace Clipboard, Clipboard, -!-, !`r`n, All
StringReplace Clipboard, Clipboard, -:-, :`r`n, All
;StringReplace Clipboard, Clipboard, -*-, `r`n, All

Send ^v ;paste

return
Default paste:

Code: Select all

You can’t retrain a dedication feat as long as you have any other feats from that archetype.
Sometimes an archetype feat grants another feat, such as the alchemist’s Basic Concoction. You must still meet the prerequisites of the feat you gain in this way.
ADDITIONAL FEATS
Some archetypes allow other feats 
Autohotkey paste:

Code: Select all

You can’t retrain a dedication feat as long as you have any other feats from that archetype.
Sometimes an archetype feat grants another feat, such as the alchemist’s Basic Concoction. You must still meet the prerequisites of the feat you gain in this way.
ADDITIONAL FEATS Some archetypes allow other feats 
Last edited by Timur Born on Wed May 18, 2022 5:12 pm, edited 1 time in total.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 5978
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy And Paste Without Linebreaks

Post by TrackerSupp-Daniel »

Hello, Timur Born

Maybe that will help, thank you for sharing!
Daniel McIntyre - Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
igorlima
User
Posts: 138
Joined: Sat Aug 22, 2020 12:16 pm

Re: Copy And Paste Without Linebreaks

Post by igorlima »

TrackerSupp-Daniel wrote: Mon May 16, 2022 8:57 pm Hello, igorlima

This appears to be working properly, there truly is a physical line break (Enter, Return character, or whatever we wish to call it these days) in that location. If you navigate to the area where that is, delete it, and replace it with a space character, before copying, the pasted text does not retain that same carriage return.

For clarity, the system we have here is not intended to remove existing line breaks, it simply prevents additional line breaks form being added where there normally are none.

Kind regards,
Hi, Daniel! I see, but I find this strange because this pdf was created from a word file and in that word file there is not extra line breaks:


image1.png
image1.png (3.01 KiB) Viewed 189 times

Timur Born wrote: Wed May 18, 2022 9:02 am The following Autohotkey script pastes clipboard content without breaks.
Thank you Timur! I will have a look
Timur Born
User
Posts: 831
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy And Paste Without Linebreaks

Post by Timur Born »

The script will also turn

re-
correr

to

recorrer

Concerning your example and Editor: I think the extra blank space after "de " is what causes the problem (extra line-break).
igorlima
User
Posts: 138
Joined: Sat Aug 22, 2020 12:16 pm

Re: Copy And Paste Without Linebreaks

Post by igorlima »

Timur Born wrote: Thu May 19, 2022 10:17 am The script will also turn

re-
correr

to

recorrer
That's wonderful!

But I can't seem to run your script here :( I'm sorry I don't used autohotkey so I don't know if I'm doing something wrong but I installed autohotkey, created the script file (attached bellow) but when I click to run it the green tray icon does not appears
Timur Born wrote: Thu May 19, 2022 10:17 am Concerning your example and Editor: I think the extra blank space after "de " is what causes the problem (extra line-break).
but the space after "de" is needed, it's supposed to be "de execução" , the problem is that when copied in the editor, its creates a line break after that space where it shouldn't be
Attachments
script.rar
(462 Bytes) Downloaded 2 times
Timur Born
User
Posts: 831
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy And Paste Without Linebreaks

Post by Timur Born »

Sorry, that wasn't the whole script, but only the part out of my big script that handles the pasting. Here is a complete script instead. You can replace the line

^!v:: Goto Paste

with

>^v:: Goto Paste

if you want to use the right-CTRL + v instead of ALT+CTRL (AltGR on German keyboard) for pasting.

Code: Select all

#NoEnv
#SingleInstance

SendMode Input

^!v:: Goto Paste

Return

Paste:

; Note for following code that `r`n = newline

;Code the paragraph breaks with a special combinations
StringReplace Clipboard, Clipboard, .`r`n, -.-, All
StringReplace Clipboard, Clipboard, ?`r`n, -?-, All
StringReplace Clipboard, Clipboard, !`r`n, -!-, All
StringReplace Clipboard, Clipboard, :`r`n, -:-, All
;StringReplace Clipboard, Clipboard, `r`n`r`n, -*-, All

;Remove a dash followed by newline, since that's probably a single word across a linebreak
StringReplace Clipboard, Clipboard, -`r`n, , All

;Replace a single newline with a space
;StringReplace Clipboard, Clipboard, %A_Space% `r`n, %A_Space%, All
;StringReplace Clipboard, Clipboard, `r`n, %A_Space%, All

;Replace multiple adjacent spaces with a single one
Clipboard := RegExReplace(Clipboard, "\s+" , " ")

;Replace the paragraph break codes with newlines
StringReplace Clipboard, Clipboard, -.-, .`r`n, All
StringReplace Clipboard, Clipboard, -?-, ?`r`n, All
StringReplace Clipboard, Clipboard, -!-, !`r`n, All
StringReplace Clipboard, Clipboard, -:-, :`r`n, All
;StringReplace Clipboard, Clipboard, -*-, `r`n, All

Send ^v ;paste

return

David.P
User
Posts: 1238
Joined: Thu Feb 28, 2008 8:16 pm

Re: Copy And Paste Without Linebreaks

Post by David.P »

That's some cool & compact coding right there Timur, even neatly formatted and annotated

Image
David.P
PDF-XChange Pro
igorlima
User
Posts: 138
Joined: Sat Aug 22, 2020 12:16 pm

Re: Copy And Paste Without Linebreaks

Post by igorlima »

Timur Born wrote: Thu May 19, 2022 11:30 am Sorry, that wasn't the whole script, but only the part out of my big script that handles the pasting. Here is a complete script instead. You can replace the line

^!v:: Goto Paste

with

>^v:: Goto Paste

if you want to use the right-CTRL + v instead of ALT+CTRL (AltGR on German keyboard) for pasting.

Code: Select all

#NoEnv
#SingleInstance

SendMode Input

^!v:: Goto Paste

Return

Paste:

; Note for following code that `r`n = newline

;Code the paragraph breaks with a special combinations
StringReplace Clipboard, Clipboard, .`r`n, -.-, All
StringReplace Clipboard, Clipboard, ?`r`n, -?-, All
StringReplace Clipboard, Clipboard, !`r`n, -!-, All
StringReplace Clipboard, Clipboard, :`r`n, -:-, All
;StringReplace Clipboard, Clipboard, `r`n`r`n, -*-, All

;Remove a dash followed by newline, since that's probably a single word across a linebreak
StringReplace Clipboard, Clipboard, -`r`n, , All

;Replace a single newline with a space
;StringReplace Clipboard, Clipboard, %A_Space% `r`n, %A_Space%, All
;StringReplace Clipboard, Clipboard, `r`n, %A_Space%, All

;Replace multiple adjacent spaces with a single one
Clipboard := RegExReplace(Clipboard, "\s+" , " ")

;Replace the paragraph break codes with newlines
StringReplace Clipboard, Clipboard, -.-, .`r`n, All
StringReplace Clipboard, Clipboard, -?-, ?`r`n, All
StringReplace Clipboard, Clipboard, -!-, !`r`n, All
StringReplace Clipboard, Clipboard, -:-, :`r`n, All
;StringReplace Clipboard, Clipboard, -*-, `r`n, All

Send ^v ;paste

return

now the script activated! thank you very much Timur!
Timur Born
User
Posts: 831
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy And Paste Without Linebreaks

Post by Timur Born »

David.P wrote: Thu May 19, 2022 4:40 pm That's some cool & compact coding right there Timur, even neatly formatted and annotated
Unfortunately I cannot claim any of the fame for myself, it is a copy & paste job of code I found on the web. ;)

There is only one piece of very small code I can at least partially claim responsibility for and even that was mostly refactoring snippets of code being thrown at me by other people. Send me a PM and I will point you to the Git.
David.P
User
Posts: 1238
Joined: Thu Feb 28, 2008 8:16 pm

Re: Copy And Paste Without Linebreaks

Post by David.P »

Oh! Now your star has dropped for me but quite a bit :wink:
David.P
PDF-XChange Pro
Timur Born
User
Posts: 831
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy And Paste Without Linebreaks

Post by Timur Born »

Maybe I can remedy that some. Just send me a short PM (cannot send you one) and I will happily have my little bit of code scrutinized by you. 8)
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 5978
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy And Paste Without Linebreaks

Post by TrackerSupp-Daniel »

Hello, Timur Born

You two seem to be having fun, I am just posting here to "close" the topic, unless there are other questions people have for public discussion.

Kind regards,
Daniel McIntyre - Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Post Reply