Cannot find paragaph spacing with Find and Replace

I use paragraph styles and somehow some of my paragraphs use a style ended up with extra spacing below the paragraph (0.20 inches; should be 0 inches). I must have gotten some direct formatting in the paragraphs by mistake. The spacing above the paragraph is correct (0.10 inches) per the style setting. I am trying to use Find and Replace, Formatting option, to find those paragraphs so I can fix them. However, the search always fails with “Search key not found”. See the attached screenshot for details:

#1 is Properties in the Navigator sidebar showing that I do have at least one paragraph with unwanted spacing below the paragraph.

#2 is Find and Replace → Formatting dialog with the spacing set to match the above paragraph and below paragraph settings that I wish to find. (If I do not set above paragraph, it defaults to 0 inches and thus would not match the paragraphs.) I do press the “OK” button to close the dialog.

#3 is Find and Replace with the formatting set to what I need to find. Pressing “Find Next”, “Find Previous”, or “Find All” always fails.

What am I doing wrong? How do I get Find and Replace to search for this formatting? (I have successfully used Find and Replace in the past for other types of formatting without problem. It is only failing for paragraph spacing.)

I am using: Version: (X86_64) / LibreOffice Community
Build ID: fcbaee479e84c6cd81291587d2ee68cba099e129
CPU threads: 20; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

I tried to reproduce your problem with LibreOffice

I formatted some paragraphs with style “Textkörper” (this should be the german equivalent for text body) having a spacing of above = 0.00 and below = 0.00 an then formatted one of the paragraphs directly with below = 0.50.
A search for spacing of above = 0.00 and below = 0.50 finds the directly formatted paragraph (as expected).

When I change the “Textkörper” style to above = 0.10 and below = 0.00 and the do again a search for spacing of above = 0.10 and below = 0.50 the search fails with “Search key not found” instead of finding my directly formatted paragraph !

Unexpected behaviour ! This is because the change of the “Textkörper” properties left both the “above” and the “below” properties of the directly formatted paragraph unchanged (i.e.: above stays = 0.00 and is thus not found).

If I only want to do a search for below = 0.50 and then klick OK, I expect that the “above” field remains undefined / empty. But when I open the formatting pane again I see that the “above” field is set to a default of 0.00 ! This means that my intended search is altered to be more narrow than I wanted.

There is an easy way to remove direct formatiing:

  • select some text
  • apply Ctrl+M
  • to see if something changed Ctrl+Z

Alternating quickly between both key presses will make affected text “blink”.

1 Like

Works for me.
Would you share the offending file? Edit your question to do that. Better if it is a reduced sample file with two or three paragraphs. Thanks.
Not sure with version 7.5, but if I select paragraphs with different spacing, the spacing field in the sidebar becomes empty.
Version: / LibreOffice Community
Build ID: 40(Build:2)
CPU threads: 1; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: es-MX (en_US.UTF-8); UI: en-US
Calc: threaded

If I understand you correctly, this alas sounds like a bug.

Thank you, but I know about Ctrl+M. It is not a solution. I cannot apply Ctrl+M to the entire document since I have many tables using direct formatting. Since the paragraphs with unwanted spacing seem to be randomly distributed throughout the document, I do not know which ones to apply Ctrl+M to, and it would be very time consuming to examine each one. Hence my question on how to use Find and Replace → Formatting to work.

I feel sure you don’need a “clumsy workaround” tampering with the XML content of the persistent representation.

Suppose the named paragraph style you find unwanted paragraph settings in - made by direct formatting (extra spacing above or below e.g.) - is named “mySpoiledStyle”.

Use F&R (Ctrl+H) with option Paragraph Styles
Enter mySpoiledStyle behind Find: using the dropdown.
Also ernter mySpoiledStyle behind Replace.
Call Replace All.

Repeat the steps for additional spoiled paragraph styles.
That’s a way to remove direct paragraph formatting while keeping direct character formatting.

1 Like

That is very clever. I will test it at some point when I have the time. If it works to expectations, I will switch the solution to your post.

I have found a clumsy work-around that avoids the tedious process of checking every paragraph for the problem. I saved the file in .fodt format (flat XML file rather than the usual .odt format). I then used a text editor to examine the document’s styles and realized it had to be an fo:margin-bottom attribute. Searching for fo:margin-bottom=“0.2in” failed to find anything!

I then found a problem paragraph that was set to a style named “P35”, which had
fo:margin-bottom=“0.1965in”. I’m assuming P35 was an automatically generated style to handle direct formatting. Further work showed this value rounded off to “0.2” when used in the Find and Replace dialog (using the .odt file). Find and Replace still failed when using 0.1965in, likely due to the unintended behavior found by nurmik. However, another search of the .fodt file found a standard style (style:name=“Standard” in the XML) with fo:margin-bottom=“0.1965in”. Somehow my problem paragraphs must have got entangled with that style, since I never created a custom style with a 0.1965in paragraph bottom spacing nor did I use direct formatting to set a paragraph to a 0.1965in bottom spacing!

It was then a simple process to search the .fodt file with the text editor and change all P## styles from fo:margin-bottom=“0.1965in” to fo:margin-bottom=“0in” (while leaving the standard styles alone so as not to break them). I saved the .fodt file, opened it in LO, and saw that the problem paragraphs were fixed! I then save the file as .odt and have not had this problem since.

All this took no more than five minutes to investigate and fix, so it was a substantial time saver over manually finding and fixing the paragraphs. So, while it would be best for Find and Replace to work properly, this .fodt workaround can be used.

1 Like

Sometimes, giving a background color to one (or more) paragraph style could help to visually differentiate them.

1 Like

That is a good suggestion; thank you.