Auto-formatting tool for removing double spaces
Auto-formatting tool for removing double spaces
I often paste content from the web into a word processor, and would like to be able to eliminate double- and even triple-spacing between paragraphs in one fell swoop. Is there any such autoformatting command that I can use that would accomplish this? I didn't see anything in the OO user guide. I looked in the autocorrect options, and only saw in the Options tab, the option to remove blank paragraphs. Is this what I want to do? Or is there another option I can use? Or would I need a macro of some kind?
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
Find and Replace will do the job. Press the Replace all button
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Auto-formatting tool for removing double spaces
I often use something like this:
Edit > Find & Replace
Search for: [:space:]+
Replace with: space
Options: Regular expressions: YES
Click "Replace all"
That will replace one or more consecutive space characters of any kind (including things like non-breaking spaces) with exactly one plain space.
Stuff that's pasted from the 'Net has all kinds of oddball junk--beside the extra spaces--in it. It could be pretty handy to have a nice way to handle it.
Edit > Find & Replace
Search for: [:space:]+
Replace with: space
Options: Regular expressions: YES
Click "Replace all"
That will replace one or more consecutive space characters of any kind (including things like non-breaking spaces) with exactly one plain space.
Stuff that's pasted from the 'Net has all kinds of oddball junk--beside the extra spaces--in it. It could be pretty handy to have a nice way to handle it.
AOO4/LO5 • Linux • Fedora 23
- Robert Tucker
- Volunteer
- Posts: 1250
- Joined: Mon Oct 08, 2007 1:34 am
- Location: Manchester UK
Re: Auto-formatting tool for removing double spaces
Do you mean it's creating extra paragraphs breaks, inserting blank paragraphs? You can eliminate these easily by installing AltSearch and searching for \p\p\p and replacing with \p\p. You might also want to look at this macro:prr wrote:I often paste content from the web into a word processor, and would like to be able to eliminate double- and even triple-spacing between paragraphs in one fell swoop.
http://www.oooforum.org/forum/viewtopic.phtml?t=6429
LibreOffice 7.x.x on Arch and Fedora.
Re: Auto-formatting tool for removing double spaces
Installed AltSearch but looking for \p\p didn't turn anything up. Not sure what the problem is. One click in MS Word does autoformatting which takes care of all of this for me. Hopefully I'll stumble across something here...
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
Can you explain exactly what you type in? What I typed in didn't come up with any hits. What do you type in with the search for, and replace with? The colon and plus sign confused me...acknak wrote:I often use something like this:
Edit > Find & Replace
Search for: [:space:]+
Replace with: space
Options: Regular expressions: YES
Click "Replace all"
That will replace one or more consecutive space characters of any kind (including things like non-breaking spaces) with exactly one plain space.
Stuff that's pasted from the 'Net has all kinds of oddball junk--beside the extra spaces--in it. It could be pretty handy to have a nice way to handle it.
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
You should type in the "Search for:" box exactly the bold text in my post:
Type one space character in the "Replace with:" box.
Make sure that the "Regular expressions" option is on; you have to click on the "More Options" button to see it.
- [:space:]+
Type one space character in the "Replace with:" box.
Make sure that the "Regular expressions" option is on; you have to click on the "More Options" button to see it.
AOO4/LO5 • Linux • Fedora 23
Re: Auto-formatting tool for removing double spaces
I just wrote a macro to do this a week ago for another person with the same request.would like to be able to eliminate double- and even triple-spacing between paragraphs in one fell swoop.
Code: Select all
Sub StripEmptyParagraphs
b = CInt(InputBox("Entry maximum empty paragraphs ( 0 is a valid entry ).",,1))
oDoc = ThisComponent
FandR = oDoc.createReplaceDescriptor
FandR.SearchRegularExpression = true
FandR.setSearchString("\n")
FandR.setReplaceString("\n")
oDoc.ReplaceAll(FandR) 'Change line breaks to paragraph breaks
oTC = oDoc.Text.createTextCursor
While oTC.isEndOfParagraph 'Remove blank paragraphs from top of doc.
oTC.goRight(1,true)
oTC.String = ""
Wend
Do While oTC.goToNextParagraph(False)
p = p + 1
Loop
oTC = oDoc.Text.createTextCursor
Do While oTC.gotoNextParagraph(false)
pc = pc + 1
If oTC.isEndOfParagraph then c = c + 1
If c > b then
Do While oTC.isEndOfParagraph
oTC.goRight(1,true)
oTC.String = ""
lc = lc + 1
If lc > p then exit do
Loop
lc = 0
c = 0
EndIf
If pc > p then exit do
Loop
End Sub
Re: Auto-formatting tool for removing double spaces
The macro works on some of these spaces between paragraphs, but not all. See, for example, this document. It will remove only a few of the large gaps.
EDIT: Acknak, thanks for clarifying your actions, but the same thing--on the attached doc, the vast majority (if not all) the spaces are not removed.
EDIT: Acknak, thanks for clarifying your actions, but the same thing--on the attached doc, the vast majority (if not all) the spaces are not removed.
- Attachments
-
- Versailles.rtf
- (49.74 KiB) Downloaded 434 times
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
When I open Versailles.rtf with OOo it is using a paragraph style with spacing both above and below the paragraph. Do Ctrl+A and apply the Default paragraph style and this spacing will go away.
Re: Auto-formatting tool for removing double spaces
In Text Body style spacing above and below the paragraph is set to 0.42cm (say 12 pts). You should check the Help file on Styles and how to modify them.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Auto-formatting tool for removing double spaces
The spaces I'm talking about are a lot greater than 2/5 of a cm.RoryOF wrote:In Text Body style spacing above and below the paragraph is set to 0.42cm (say 12 pts). You should check the Help file on Styles and how to modify them.
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
OK that is one quick solution when this happens---select all, then apply a paragraph style that has no (or just limited) spacing before and after paragraphs. That actually wouldn't even require a macro....JohnV wrote:When I open Versailles.rtf with OOo it is using a paragraph style with spacing both above and below the paragraph. Do Ctrl+A and apply the Default paragraph style and this spacing will go away.
LO 7.1.6.2 on Windows 10
Re: Auto-formatting tool for removing double spaces
They are most probably 0.42 cm after the para above and 0.42cm before the para below. Modify your Text Body Style to remove these two settings and see where that gets you.prr wrote:The spaces I'm talking about are a lot greater than 2/5 of a cm.RoryOF wrote:In Text Body style spacing above and below the paragraph is set to 0.42cm (say 12 pts). You should check the Help file on Styles and how to modify them.
Edit: Also, turn ON Display Formatting characters and look at your file again. There are several extra paragraph marks which need to be removed. |
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Auto-formatting tool for removing double spaces
I am having the opposite problem - I have text with a mixture of single and double spacing and I would like to make sure it is all double spaced. I tried replacing ". " with ". " but this adds the extra space to an existing double space. Is there a code for a non-space character? e.g. say * = represents any letter or number I could replace ". *" with ". *"
Thanks
Murph
Thanks
Murph
OOo 3.2.1, WinXP
- Robert Tucker
- Volunteer
- Posts: 1250
- Joined: Mon Oct 08, 2007 1:34 am
- Location: Manchester UK
Re: Auto-formatting tool for removing double spaces
Search: ([^:space:]) ([^:space:])Murph wrote:I am having the opposite problem - I have text with a mixture of single and double spacing and I would like to make sure it is all double spaced. I tried replacing ". " with ". " but this adds the extra space to an existing double space. Is there a code for a non-space character? e.g. say * = represents any letter or number I could replace ". *" with ". *"
Replace: $1 $2
(Regular expressions checked, of course)
for some reason has a problem with "I"s.
You could replace all spaces by two spaces then repeatedly replace three spaces by two spaces until no more three spaces are found.
LibreOffice 7.x.x on Arch and Fedora.
Re: Auto-formatting tool for removing double spaces
I don't think does what you expect it to doSearch: ([^:space:]) ([^:space:])
I think it should work if you just use plain spaces in the pattern: ([^_])_([^_]) (where the "_" represents a plain space character).
AOO4/LO5 • Linux • Fedora 23
- Robert Tucker
- Volunteer
- Posts: 1250
- Joined: Mon Oct 08, 2007 1:34 am
- Location: Manchester UK
Re: Auto-formatting tool for removing double spaces
No. I thought it would find any character except a space separated by a space from any character except a space. It does but not when an "I" is involved. I'd be interested in the explanation for that.acknak wrote:I don't think does what you expect it to doSearch: ([^:space:]) ([^:space:])
Yes, I'd tried with (^ ) (^ ) but didn't have any success, of course.acknak wrote:I think it should work if you just use plain spaces in the pattern: ([^_])_([^_]) (where the "_" represents a plain space character).
LibreOffice 7.x.x on Arch and Fedora.
Re: Auto-formatting tool for removing double spaces
It does but not when an "I" is involved. I'd be interested in the explanation for that.
At least I think that's what happens--does that square with your "I" example?
Anything other than "[:space:]" is not recognized as the named class. So [^:space:] is a plain, ordinary character class: it matches any character except the letters s, p, a, c, e or colon.Robert Tucker wrote:No. I thought it would find any character except a space separated by a space from any character except a space. It does but not when an "I" is involved. I'd be interested in the explanation for that.acknak wrote:I don't think does what you expect it to doSearch: ([^:space:]) ([^:space:])
At least I think that's what happens--does that square with your "I" example?
AOO4/LO5 • Linux • Fedora 23
- Robert Tucker
- Volunteer
- Posts: 1250
- Joined: Mon Oct 08, 2007 1:34 am
- Location: Manchester UK
Re: Auto-formatting tool for removing double spaces
Looking at it again it seems more than the "I"s are affected. I get this result for Search for: ([^:space:]) ([^:space:]) Replace with: $1 $2.acknak wrote:...does that square with your "I" example?
Before: After: From your explanation I can understand that it doesn't change to a double-space between "opposite" and "problem". But why no double-space between "I" and "am" and "the" and "opposite" and so on?
LibreOffice 7.x.x on Arch and Fedora.
Re: Auto-formatting tool for removing double spaces
There's another problem when single non-space characters are both preceded by a space and followed by a space. During a first run of Search and Replace, the combination of a character-space-"I" is found and replaced. The search then continues with the space following "I", so the combination of "I"-space-character isn't found during the first run. Search and Replace has to be run a second time to find the "I"-space-character combinations.
Re: Auto-formatting tool for removing double spaces
The entire pattern has to match--if either one of the characters around the space matches the excluded class, the whole pattern fails to match. So "I a" doesn't match because "a" is a member of the excluded set; "e o" because "e" is excluded.... why no double-space between "I" and "am" and "the" and "opposite" and so on?
The problem posed is tough to do with a regular expression for English prose because English has complicated rules for punctuation. It often requires some analysis of the context to determine for sure where the end of a sentence is--at least for the general case.
AOO4/LO5 • Linux • Fedora 23
-
- Posts: 1
- Joined: Sun Aug 19, 2012 3:04 pm
Re: Auto-formatting tool for removing double spaces
Acknak's remedy resolve the same issue in LibreOffice 3.5. I was searching for the the tag in LibreOffice and after applying all of it, nothing worked. I know OpenOffice uses the same source code as LibreOffice so I googled the tag, this time instead of LibreOffice, I used OpenOffice. I tried Acknak''s remedy which was slightly different than that in LibreOffice' community. It worked. Thanks acknak.
LibreOffice 3.5
-
- Posts: 17
- Joined: Sun Dec 16, 2012 3:17 am
Re: Auto-formatting tool for removing double spaces
[quote="acknak" quote] Thanks so much. I’ve spend days looking for this solution. Typing [:space:]+ into the Find All box works like a charm. But ‘typing one space character’ into the Replace All box needs clarification. There’s no “character” for one space, instead you have to just press the space bar once ... be careful that the cursor is in position before you press that space bar. Only ONCE. What is confusing is that the space bar doesn’t show anything in the Replace All box. The cursor has merely advanced one space.
This works like a charm, but I’ve pulled out half my hair searching for it.
This works like a charm, but I’ve pulled out half my hair searching for it.
OpenOffice 3.1 on Windows Vista
Re: Auto-formatting tool for removing double spaces
A space is a character. It's the first "printable" character on the list of ASCII characters.
ASCII
ascii codes
ASCII
ascii codes
AOO 4.1.14 on Ubuntu MATE 22.04
-
- Posts: 17
- Joined: Sun Dec 16, 2012 3:17 am
Re: Auto-formatting tool for removing double spaces
Sorry, I stand corrected ... I was confused by the blank space. I followed your link ASCII and it is as complex String Theory. There are so many queries regarding this simple operation that I'm guessing I'm not alone in my befuddlement. "Hit the Space Bar once" would have solved the problem.
OpenOffice 3.1 on Windows Vista