DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Double to Single Space Converter  (Read 11,656 times)

HOTGA

  • We code in peace - take us to your leader....
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 12
Double to Single Space Converter
« on: November 09, 2009, 05:05 AM »
Please can some one write a program to convert double and triple spaces in text copied from pdf's and word document to single space. I cut a lot of text from pdf documents into word tables and it always has double and sometimes triple spaces between the text and I have to do lots of find and replace in word to change double to single space (sometimes multiple times on the same piece of text) - use this program (http://www.freewaregenius.com/2007/07/04/clipcase/) "ClipCase" to try to this but it never works on the double spaces - HELP!!

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Double to Single Space Converter
« Reply #1 on: November 09, 2009, 05:32 AM »
you can use a clipboard tool like my Clipboard Help+Spell and define a text formatting preset to do this; then just select your text and hit a hotkey and run the text formatter on it to do what you want.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: Double to Single Space Converter
« Reply #2 on: November 09, 2009, 07:45 AM »
try this AHK script to replace the unwanted whitespaces with one single whitespace. use the win+alt+v hotkey to process the clipboard and paste the content.

Code
#!v::
clipboard = %clipboard%   ; change to plain text
clipnospace := RegExReplace(clipboard, "` {2,}", "` ")
clipboard = %clipnospace%
Send ^v 
Return

HOTGA

  • We code in peace - take us to your leader....
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 12
Re: Double to Single Space Converter
« Reply #3 on: November 09, 2009, 07:52 AM »
I have d/l'dclipboard help and spell - thanks - please tell me what type in the find and replace box of the modify format/case settings - I tried normal double space replaced with single - does not work, [:space:] replaced with [:space:][:space:] - does not work, [:space:]{2} replaced with normal space not luck! HELP (please)

HOTGA

  • We code in peace - take us to your leader....
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 12
Re: Double to Single Space Converter
« Reply #4 on: November 09, 2009, 08:14 AM »
Cheers lanux edited the script so my single key shortcut for puretext.exe also removes all double spaces! ace..thanks for your help too mouser!

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Double to Single Space Converter
« Reply #5 on: November 09, 2009, 08:17 AM »
Ok here you go, the CHS screenshot configuration for the preset:
Screenshot - 11_9_2009 , 2_12_55 AM.png

Even easier, just unzip this preset.format file in your C:\Program Files (x86)\Clipboard Help+Spell\PresetFormats\ directory, restart CHS, and you should now have it available without having to create and save it yourself:
MultiSpaceToSingle.preset.zip (671 B)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Double to Single Space Converter
« Reply #6 on: November 09, 2009, 08:18 AM »
damn it lanux beat me to it :)

well.. at least this will be useful for those who feel like experimenting with CHS.

Original address: https://www.donationcoder.com/forum/index.php?topic=20557.0