Replacing two "enter keys" with one "enter key."

It is with great absurdity that I post this question. I do not know why my kit: Writer Version: 5.2.2.2, does not work as suggested in the posts I’ve tried, but it does not. This feels like a “where’s the `anykey’ key?” question, but it is not. It is a simple search and replace task. And I’ve worked with RE/PCRE for a very long time. (I love sed!)

I need to replace: “ENTERKEY”“ENTERKEY” with “ENTERKEY”. That’s as literal as I can state it. In ODT format, “ENTERKEY”“ENTERKEY” produces:

<text:p text:style-name=“Text_20_body”/><text:p text:style-name=“Text_20_body”/>

which is literal to the “content.xml” file, but not useful within LO Writer. So, does anyone have a list of text equivalents of these ODT objects? PCRE even? That work?

I think part of the trouble is that LO Writer had to convert screen content into buffer content, both ways. From the file to the screen, and from the user input into whatever its internal format happens to be. Since ODT seems to be (is) css type markup nested inside xml makrup tags, “source” options would be very powerful indeed.

For now, I’d like to search and replace these double thingees with a single thingee.

There exists a direct option to remove blank paragraphs. First go to Tools > AutoCorrect > AutoCorrect Options. In tab “Options” mark the option “Remove blank paragraphs” in column [M] (and only this). Close the dialog. Then again Tools > AutoCorrect, and now item “Apply”.

The problem is that LibreOffice built-in Find and Replace works within one paragraph only. You may find empty paragraph (^$) or any paragraph end ($) and replace it with something; but there’s no way to do what you need in one pass. You could replace all paragraph marks with a temp dummy sequence, and then replace double sequences with \n, and then sequences left with \n.

But actually, using AltSearch extension might be much more comfortable.

If you, however, just need to remove all empty paragraphs, then the easiest way is to search for ^$ and replace with empty string (using built-in Find and Replace).

Thank you Mike, for the reply. I was gathering that.

AltSearch did not help either. I’m probably not using it correctly.

No is not acceptable.

“Can’t” is absurd after all these years.

“Only” is a M$ habit, not GNU/Linux, nor LO by extension.

I fixed it with sed:

s%</text:p><text:p text:style-name=“Text_20_body”/><text:p text:style-name=“Text_20_body”/><text:h text:style-name=“Heading_20_2” text:outline-level=“2”>%</text:p><text:p text:style-name=“Text_20_body”/><text:h text:style-name=“Heading_20_2” text:outline-level=“2”>%g

in about as much time as it took for me to take my hand from the keyboard. This is very scriptable.

When I do not find an answer out there, it is often because the product “can’t” do it.

I feel for the regular user. I’ve moved students from LO to MS Office over stuff like this. Even though they liked FOSS, they needed to get their course work done. And LO wouldn’t do it, cause of little (big) things like this.

So. Looks like an opportunity! ODT is what we’re actually working with; enabling source editing would go a loooong way to improving LO. Lots of folks are comfortable with css. This sort of thing is becoming a part of common literacy among contemporary information practitioners. LO needs to provide access, or count itself a compromised product. IMHO.

LO complained about the corrupt file, but “repaired” it, and it works.

Does anyone know of a better solution?

Well, just wanted to mention that if you need to work with ODF XML, then possibly best is to use Flat ODF (FODT) format. Having said that, there are problems with it when objects are embedded into documents: see e.g. tdf#63642.

I saw that on wiki. My LO5 support flat xml/fodt. I like the regular file format in that it separates content from presentation. On the hack, I got it to work first try, and running the file through an archive routine is easier than it sounds. I’m playing with it some more…