Bug 167999 - Writer, EDITING: Deleting empty paragraphs using "Find and Replace" also deletes auto-generated chapter headers
Summary: Writer, EDITING: Deleting empty paragraphs using "Find and Replace" also dele...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
24.8.5.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2025-08-18 15:03 UTC by anonaned
Modified: 2025-08-26 17:12 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
A document consisting of auto-generated headings and some other, unformatted text (48.53 KB, application/vnd.oasis.opendocument.text)
2025-08-19 14:43 UTC, anonaned
Details
Automatic.Numbered.Headings.with.Empty.Paragraphs[LO25.2.5].odt (16.48 KB, application/vnd.oasis.opendocument.text)
2025-08-21 06:16 UTC, Tex2002ans
Details

Note You need to log in before you can comment on or make changes to this bug.
Description anonaned 2025-08-18 15:03:53 UTC
Description:
My document consists of two paragraph styles:
- Heading (H1), which I created myself using "Tools - Heading Numbering - Numbering". The headings are fully auto-generated and do not contain plain text. They are in the style of "Chapter 1", "Chapter 2", etc. I created them like this: https://help.libreoffice.org/latest/en-US/text/swriter/guide/header_with_chapter.html
- Body text which I pasted into the document using "Paste Unformatted Text". It's some paragraphs of plain text seperated by true empty paragraphs ("Formatting Marks" shows pilcrows, not line breaks).

Problem: The pasted text contains empty paragraphs which I wanted to delete using "Find and Replace". Regular Expressions turned on, Find: "^$", Replace with: [BLANK]. This found all empty paragraphs, but also my auto-generated chapter headings as they don't have any plain text. Deleting the empty paragraphs would therefore also delete the auto-generated chapter headings.

Workaround: Instead of using only fully automated chapter headings I could add some text manually to each auto-generated heading, but this defeats the purpose of auto-generating the headings in the first place...

Steps to Reproduce:
1. Create chapter headings via "Tools - Heading Numbering - Numbering". (Select the numbering scheme 1, 2, 3, ...; Begin with: 1; Paragraph style: Heading 1; Before: "Chapter ")
2. Create a few paragraphs using the return key.
3. Select those paragraphs and change them to "Heading 1" style. This should create fields called Chapter 1, Chapter 2, etc.
4. Use "Find and Replace", Regular Expressions turned on, Find: "^$", Replace with: [BLANK].

Actual Results:
This deletes the auto-generated headings.

Expected Results:
The auto-generated headings shouldn't be deleted.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
I first encountered this bug using an older version (the one I mentioned above).

Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
CPU threads: 4; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded
Comment 1 m_a_riosv 2025-08-18 22:06:39 UTC
Please attach a sample file, reduce the size as much as possible without private information.
Comment 2 anonaned 2025-08-19 14:43:54 UTC
Created attachment 202382 [details]
A document consisting of auto-generated headings and some other, unformatted text

The file is an example of my document. The following link shows a screenshot of me trying to delete all empty paragraphs using "Find and Replace" as detailed in the original report: https://i.imgur.com/rbWzmG5.png
Comment 3 anonaned 2025-08-19 14:46:22 UTC
Ive uploaded an .odt document that shows my setup. Here's a screenshot of me trying to delete the empty paragraphs using "Find and Replace". It finds not only the empty paragraphs, but also the auto-generated chapter headings.
https://i.imgur.com/rbWzmG5.png
Comment 4 m_a_riosv 2025-08-19 21:46:34 UTC
Those Heading paragraphs are empty paragraphs, they have no text.
Comment 5 anonaned 2025-08-20 06:37:49 UTC
Yes, I am aware they have no plain text. So in this case (my original document was 100+ pages and 25 headings) my only choice of removing the empty paragraphs in the text via Find and Replace is to add some characters manually to each and every heading? I'm asking because I'm using the auto-generated headings to save time, needing to manually adjust them kind of defeats their purpose.
Comment 6 m_a_riosv 2025-08-20 21:59:05 UTC
Please, search for an answer or ask for one in https://ask.libreoffice.org
Comment 7 Tex2002ans 2025-08-21 06:16:29 UTC
Created attachment 202420 [details]
Automatic.Numbered.Headings.with.Empty.Paragraphs[LO25.2.5].odt
Comment 8 Tex2002ans 2025-08-21 06:21:14 UTC
It seems like Comment #0 didn't describe it as well as it could have been.

I was able to reproduce it using Attachment #202420 [details] (my simplified document) using this version:

Version: 25.2.5.2 (X86_64) / LibreOffice Community
Build ID: 03d19516eb2e1dd5d4ccd751a0d6f35f35e08022
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

with more discussion/details at the OP's original bug here:

- https://www.reddit.com/r/libreoffice/comments/1meu615/writer_deleting_empty_lines_without_deleting/n6hhp7a/

- - - - - -

### An "empty" Heading Numbering bug (Regular Expression Find and Replace issue)

In Writer:

0. Open the attached ODT.

1. Edit > Find and Replace (Ctrl+H)

2. At the bottom of the window:

- Expand "Other Options".

3. Turn ON the "Regular Expressions" checkbox.

4. Type:

- Find: ^$
- Replace:
--- Leave it COMPLETELY BLANK

5. Press "Replace All".

BUG: All those paragraphs with auto-generated chapter names disappear:

Before:

- Chapter 1 Test 1
- Chapter 2
- Chapter 3
- [...]
- Chapter 10

After:

- Chapter 1 Test 1

EXPECTED: For the auto-generated headings to not be deleted:

- Chapter 1 Test 1
- Chapter 2
- Chapter 3
- [...]
- Chapter 10

- - - - - -

### Why Were We Doing This?

We were trying to remove all double "ENTER ENTERs" from the book, but it accidentally wiped away all the numbered chapter headings as well.

### Note On How I Produced The ODT

1. Press ENTER 5 times.

2. Ctrl+A to highlight all 5 paragraphs.

3. Ctrl+1 to change them all the "Heading 1" Style.

4. Tools > Heading Numbering.

5. In the "Heading Numbering" window:

- Go to the "Numbering" tab.

then change each of these:

- "Number" dropdown:
--- 1, 2, 3, ...
- "Before" box:
--- Chapter 
----- Make sure there's a SPACE after the word "Chapter " <----!!!
- "After" box:
--- :
----- A single COLON.

6. Press OK.

Now, you get those "empty" automatic chapter numberings.

This was mostly following the official LibreOffice Help instructions:

- LibreOffice 25.2 Help: "Inserting a Chapter Name and Number in a Header or a Footer"
- https://help.libreoffice.org/25.2/en-US/text/swriter/guide/header_with_chapter.html