Remove line breaks while copying (Convert multiple lines to one line)
Posted: 31 Jan 2023, 11:18
I work with pdfs a lot. When copying text from pdf it also copies line breaks in pdf. I usually solve this by opening a new Chrome tab, pasting the text to address bar (it automatically converts it to one line text), then copying it again. However, I wanted to increase my productivity. So, the following code automatically removes line breaks of selected text and copy it as a one line text when you press Ctrl+C.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
^c::
Suspend, On ; Suspend this scripts so the following ^c becomes a normal copy
Clipboard =
Send, ^c
Sleep, 50 ; Wait for clipboard
Clipboard := RegExReplace(Clipboard, "\r\n|\r|\n", "")
Suspend, Off
return