9

Is there a program, or a clipboard manager with a plugin for Windows that can automatically trim the beginning and ending whitespace from text copied into the clipboard before pasting?

I've found many clipboard manager programs, but none that specifically list this feature. There is a discussion in the AutoHotkey forums about doing this, with no solid answer. I emailed the developer of PureText my idea and he said he will try to work this option into his program when he gets the chance.

Is there a good clipboard manager which auto-trims whitespace?

5

I looked up every single clipboard manager program and finally found one that automatically scrubs whitespace from the beginning and end of copied text.

http://www.clipboardfusion.com/

It can play a sound when the whitespace is "scrubbed" and there are optional find-and-replace options too. Really nice.

  • 1
    Great answer, I had forgotten about it! Fusion people have some nice software to improve Windows. (I use DisplayFusion) – Franck Dernoncourt Aug 21 '14 at 15:14
1

I personally use the voice-recognition software Dragon NaturallySpeaking to handle copy-pasting operations. By default, I trim the text when I say the command copy, which I wrote in advanced scripting, as the following (as you can see it is not very advanced):

Sub Main
    Clipboard(Trim(Clipboard))
End Sub

Documentation on Trim():

Returns a string that contains a copy of a specified string without leading spaces (LTrim), without trailing spaces (RTrim), or without leading or trailing spaces (Trim):

Public Shared Function LTrim(ByVal str As String) As String
Public Shared Function RTrim(ByVal str As String) As String
Public Shared Function Trim(ByVal str As String) As String

PS: (unrelated to Dragon) http://outertech.com/en/clipboard-history does trailing only.

1

You can use a script to do it with AutoHotkey (scripting language for desktop automation on Windows):

~^v::
Trimmed := RegExReplace(Clipboard, "^\s+", "")
Trimmed := RegExReplace(Trimmed, "\s+$", "")
Clipboard = %Trimmed%
return
  • Thank you Franck for the answer. A word of warning to anyone using this; it seems that AutoHotkey is a bit too slow if you copy/paste extremely fast. For now I am using it, but it "misses" what I copy sometimes if I paste immediately. I don't have any knowledge on how AH binds to key combinations to fix this. – degenerate Jul 9 '14 at 19:06
  • 1
    @degenerate Thanks for the edit, yes I guess that's why they use ClipWait 0.5 ; Wait up to .5 seconds in the original script. I agree it's quite a pain, I have some similar issues with Dragon NaturallySpeaking's advanced scripting, probably some Windows limitations (but I would be curious to have some in-depth explanations). – Franck Dernoncourt Jul 9 '14 at 19:30
  • @FranckDernoncourt The latest version of AutoHotkey (AHK_L) can do it even better. ~^v::Clipboard := Trim(Clipboard, "rn t")` – Avi Aug 8 '14 at 5:49
  • @FranckDernoncourt Sorry, the code is formatted incorrectly. ~^v::Clipboard := Trim(Clipboard, "`r`n `t") – Avi Aug 8 '14 at 5:55
  • Unfortunately while this answer works, it's still not ideal. Copy-pasting very quickly is too fast for AutoHotkey and it doesn't have the time to edit the clipboard contents before I paste. I am still looking for alternatives if anyone knows one. – degenerate Aug 21 '14 at 14:15
0

You can also do it with the Spartan clipboard manager. I work for them so I'm biased but it does the job nicely. You even have the option to have it happen when you Ctrl+C then Ctrl+v without having to refer to the program at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.