Clean Paste

While there are times that I appreciate the way copy-paste retains formatting in Windows, it very frequently causes headaches. Some of the applications in the Office suite provide the ability to paste without formatting, but there are still many times that unwanted formatting tags along or causes problems.

AutoHotKey to the rescue!

The following little script lets me hit the Windows key and “v” and get a clean paste without formatting:

; Copied from
#v:: ; Text–only paste from ClipBoard | WIN and V keys are the hotkey
KeyWait, LWin ; Wait for the Windows key to be lifted,
KeyWait, RWin ; since it would sometimes combine with the pasted text.
OldClip = %ClipBoardAll% ; Save formatted text for later
ClipBoard = %ClipBoard% ; Convert to text
Send ^v ; For best compatibility: SendPlay | simulates pressing CRTL and V keys
Sleep 50 ; Don't change clipboard while it is pasted! (Sleep > 0)
ClipBoard = %OldClip% ; Restore original ClipBoard
VarSetCapacity(OldClip, 0) ; Free memory

view raw
hosted with ❤ by GitHub

This is pretty much just copied from a forum post. Nice and fast and no bad formatting.

Clean Paste

2 thoughts on “Clean Paste

  1. Ben Butina says:

    Good little solution. Seems to me that I need a “clean” paste about 10 times as often as I need a formatted paste.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s