Unable to Find and Replace double-spaces to single-spaces

Discuss the word processor
Post Reply
John Doyle
Posts: 5
Joined: Fri Jan 12, 2018 11:18 pm

Unable to Find and Replace double-spaces to single-spaces

Post by John Doyle »

Within the body of a document, using Ver. 4.1.5, I am unable to Find and Replace double spaces between sentences to single spaces. It's my impression in former versions, I was able to enter two spaces at the Find prompt and a single space at the Replace prompt, and the entire document would be changed.

In Ver. 4.1.5., I have not yet found a way to simply enter the two spaces in Find and a single space in Replace and have any changes made. I get a "not found" notice, and all double spaces at the end of sentences go unchanged.

EXAMPLE:
This is the first sentence. This is the second, following TWO SPACES

Need to change to:

This is the first sentence. This is the second, following ONE SPACE.

Thanks for any insight,
John D.
OpenOffice 4.1.5 on Windows 7
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Unable to Find and Replace double-spaces to single-space

Post by RoryOF »

Works for me. Make certain to drop "More options" and check that Regular Expressions is unchecked.
 Edit: it is possible that a double space at the start or the end of the document may not be found and replaced (I'm not certain about this)' best to turn on /View /non printing characters so that you can see these occurrences. 
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John Doyle
Posts: 5
Joined: Fri Jan 12, 2018 11:18 pm

Re: Unable to Find and Replace double-spaces to single-space

Post by John Doyle »

Thanks, Rory,
Can you tell me in which section(s) I'll find: "More Options" and"Regular Expressions," please?
Many thanks,
John D.
OpenOffice 4.1.5 on Windows 7
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Unable to Find and Replace double-spaces to single-space

Post by RoryOF »

On the Find and Replace dialog you will see a dropdown for More Options. When you drop that down Regular Expressions is offered (amongst other options). Try this using the attached file - there should be 11 occurrences of double spaces. To find these enter ". " (<full stop><space><space> in Find), and ". " (<full stop><space>) in Replace.
Attachments
Two spaces.odt
(12.12 KiB) Downloaded 105 times
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Unable to Find and Replace double-spaces to single-space

Post by RoryOF »

I have installed Language Tool; as I type this will indicate two spaces by a wiggly blue underline (and some other errors also). I believe in a double space after a full stop or !, ?, to better set off a sentence. My choice - yours may differ. Chicago Manual of Style doesn't agree with me, but they are entitled to their opinion.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John Doyle
Posts: 5
Joined: Fri Jan 12, 2018 11:18 pm

Re: Unable to Find and Replace double-spaces to single-space

Post by John Doyle »

Is Language Tool a part of Open Office? I don't recall using it.

Thanks,
John
OpenOffice 4.1.5 on Windows 7
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Unable to Find and Replace double-spaces to single-space

Post by John_Ha »

Works fine for me. I typed two spaces in Find and one space in Replace. I then clicked Find and it found the first occurrence. Replace All changed both occurrences of two spaces with one space.
Clipboard01.gif
See [Tutorial] How to record a macro (and Regular Expressions)

As a new poster you will find much useful information in the Writer FAQ, the Writer Tutorials, the up to date Writer guide and the Writer Manual. When a pop-up window opens, click the Help button for extensive help on that function - it is often more comprehensive than the manual.

If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
Last edited by John_Ha on Sat Jan 13, 2018 1:06 am, edited 1 time in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John Doyle
Posts: 5
Joined: Fri Jan 12, 2018 11:18 pm

Re: Unable to Find and Replace double-spaces to single-space

Post by John Doyle »

Hi John,

Just checking... This is with Open Office 4.1.5?
The procedure you describe is exactly what I used for years on an earlier version of Open Office with no problems.
I also have nothing selected under "Fewer Options" on my new 4.1.5 installation.
What's confounding is that it seems to "Find" double-spaces on *some* files, but not on all. Makes no sense.
OpenOffice 4.1.5 on Windows 7
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Unable to Find and Replace double-spaces to single-space

Post by JohnV »

I had no problem with this either.
4.1.5 under Windows 10.
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Unable to Find and Replace double-spaces to single-space

Post by John_Ha »

I am using a vanilla 4.1.5.

I think I know why it is happening sometimes and not others. It is the difference between a space and a required or non-breaking space, especially as copied from an e-mail. I use Thunderbird and if I type "fred fred fred fred", with two spaces between each word, one (second) is a normal space and the other (first) is a required space. When I copy the phrase into AOO and search for double spaces it does not find them. See attached fred.odt.

They are also known as non-breaking spaces and can be entered by ctrl+shift+space. non-breaking spaces are used where you do not want two words ever to be placed on separate lines. For example, vice[non-breaking space]versa will never be split: either nothing will spill to the next line, or both words will spill as a unit.
Required spaces are shaded grey when Tools &gt; Options &gt; OO Writer &gt; View &gt; Field codes is ticked.
Required spaces are shaded grey when Tools > Options > OO Writer > View > Field codes is ticked.
Clipboard02.gif (17.33 KiB) Viewed 3121 times
I am pretty sure that in 4.1.4 and earlier, the required spaces were always painted grey. I can only get them to paint grey now by going View > Field Names.

I can also get them to be grey by Tools > Options > OO Writer > View ..., and ticking Field codes. I then do not need View > Field Names to be selected. Perhaps I have changed this setting recently.


They can be made visible by Tools > Options > OpenOffice Writer > Formatting aids > tick Display Non breaking spaces

If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
Attachments
fred.odt
(8.88 KiB) Downloaded 69 times
Last edited by John_Ha on Sat Jan 13, 2018 7:12 pm, edited 2 times in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John Doyle
Posts: 5
Joined: Fri Jan 12, 2018 11:18 pm

Re: Unable to Find and Replace double-spaces to single-space

Post by John Doyle »

John,

JUST GOT YOUR LATEST. MY PREVIOUS REPLY IS BELOW THIS RESPONSE:

Thanks for the FRED experiment. I'll take a close look later this evening.
I appreciate the help!

John

________________________________

EARLIER RESPONSE:

I'm using Windows 7 on a PC. I wonder if Ver. 4.1.5. doesn't like Windows Ver. 7.

As an alternate possible solution, can you tell me how I can successfully go BACK to my older Ver. 4.1.2? When I execute the 4.1.2 installation, it "finds" 4.1.5 and installs it instead. I have the original installation files for 4.1.2. but attempting to install *them* directly does not work. I always end up with 4.1.5.

Can I safely DELETE all existing Open Office *program files* without losing access to several years of saved Open Office .DOC files?
Thanks,
John
OpenOffice 4.1.5 on Windows 7
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Unable to Find and Replace double-spaces to single-space

Post by John_Ha »

Testing by searching for a single space shows that only the normal space is found.

I am pretty sure that something has changed here recently because I am almost certain that previously, searching by typing a space in Find found both normal and required spaces.
 Edit: See post below - that statement is wrong 
Last edited by John_Ha on Sat Jan 13, 2018 7:06 pm, edited 2 times in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Unable to Find and Replace double-spaces to single-space

Post by John_Ha »

John Doyle wrote:I'm using Windows 7 on a PC. I wonder if Ver. 4.1.5. doesn't like Windows Ver. 7.
I doubt it - it is much more likely to be an inadvertent error in 4.1.5.
John Doyle wrote:As an alternate possible solution, can you tell me how I can successfully go BACK to my older Ver. 4.1.2
1. Uninstall 4.1.5.
2. Rename C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4 to C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4_OLD 415
3. Download and install 4.1.x and install it. This creates a new, default C:\Users\xxxxxx\AppData\Roaming\OpenOffice\4

If you want to keep (nearly) all your settings, but at the slight risk of messing things up (programs are forwards compatible but may not be backwards compatible) then:

4. Start AOO. Stop AOO
5. Copy back everything from ...\4_OLD 415 to ...\4 except do not copy registrymodifications.xcu and \config.

Uninstalling and re-installing AOO does not affect your documents.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Unable to Find and Replace double-spaces to single-space

Post by John_Ha »

John_Ha wrote:I am pretty sure that something has changed here recently because I am almost certain that previously, searching by typing a space in Find found both normal and required spaces.
I was wrong there.

I do know that when I use the macros below to search for required spaces, and to replace them by normal spaces, before doing more comprehensive searching and replacing to set my house style, the macro finds both normal and required spaces. The macro still works in 4.1.5. I am always bemused that the search command

Code: Select all

FindReplaceRegExp (" "," ","all")                                 ' change required space to space
appears to use normal spaces in both places yet replaces required spaces by normal spaces . I forget what I did but perhaps I recorded a macro where I copied a required space and pasted it into the search box, and then hacked the recorded macro to get the space symbol used, which I then pasted in the search argument in the command line on my macro.

Code: Select all

sub Rqd_to_normal
   REM save cursor position
   oViewCursor = ThisComponent.getCurrentController().getViewCursor()
   oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)

   REM disable screen update
   ThisComponent.lockControllers
   ThisComponent.CurrentController.Frame.ContainerWindow.Enable = False

   FindReplaceRegExp (" "," ","all")                                 ' change required space to space

   REM restore cursor position
   oViewCursor = ThisComponent.getCurrentController().getViewCursor()
   oViewCursor.gotoRange(oTextCursor,false)
   
   REM reenable screen update
   ThisComponent.CurrentController.Frame.ContainerWindow.Enable = True
   ThisComponent.unlockControllers

End Sub

Sub FindReplaceRegExp (sFind,sReplace,sScope)

   REM sFind: regular expression
   REM sReplace: if empty, function selects all occurrences of sFind
   REM sScope: set to "all" for entire document, or "selection" to restrict the scope.
   REM function searches backwards (necessary to correctly catch quotes)

   dim document   as object
   dim dispatcher as object
   document   = ThisComponent.CurrentController.Frame
   dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

   dim args1(18) as new com.sun.star.beans.PropertyValue
   args1(0).Name = "SearchItem.StyleFamily"
   args1(0).Value = 2
   args1(1).Name = "SearchItem.CellType"
   args1(1).Value = 0
   args1(2).Name = "SearchItem.RowDirection"
   args1(2).Value = true
   args1(3).Name = "SearchItem.AllTables"
   args1(3).Value = false
   args1(4).Name = "SearchItem.Backward"
   args1(4).Value = true
   args1(5).Name = "SearchItem.Pattern"
   args1(5).Value = false
   args1(6).Name = "SearchItem.Content"
   args1(6).Value = false
   args1(7).Name = "SearchItem.AsianOptions"
   args1(7).Value = false
   args1(8).Name = "SearchItem.AlgorithmType"
   args1(8).Value = 1
   args1(9).Name = "SearchItem.SearchFlags"
   If sScope = "all" Then
      args1(9).Value = 65536   ' parse entire doc
   Else
      args1(9).Value = 71680   ' parse selection only
   End If
   args1(10).Name = "SearchItem.SearchString"
   args1(10).Value = sFind
   args1(11).Name = "SearchItem.ReplaceString"
   args1(11).Value = sReplace
   args1(12).Name = "SearchItem.Locale"
   args1(12).Value = 255
   args1(13).Name = "SearchItem.ChangedChars"
   args1(13).Value = 2
   args1(14).Name = "SearchItem.DeletedChars"
   args1(14).Value = 2
   args1(15).Name = "SearchItem.InsertedChars"
   args1(15).Value = 2
   args1(16).Name = "SearchItem.TransliterateFlags"
   args1(16).Value = 1280
   args1(17).Name = "SearchItem.Command"
   If sReplace = "" Then
      args1(17).Value = 1      ' find all
   Else
      args1(17).Value = 3      ' replace all
   End If
   args1(18).Name = "Quiet"
   args1(18).Value = true
   dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())

End Sub
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Post Reply