Replace two line breaks

I am trying to kick the microsoft habit and one of the things I use Word for is removing unnecessary line breaks (paragraph marks). In Word, I start by protecting necessary line breaks by replacing two line breaks with two tab characters. Then I replace unnecessary line breaks with spaces. Then I replace two spaces with one. Then I replace two tab characters with one line break. And like magic the unnecessary line breaks are gone.

(In Word ^p is a line break and ^t is a tab. )

In LO when I search $ with Regular Expressions checked it searches for line breaks, but it won’t let me search for two line breaks.

I would love some help troubleshooting this so I can get away from the microsoft monster.

@January
Have you ever tested AltSearch.oxt v. 1.4.2?
It can search a sequence of empty paragraphs and replace them with one.


Note:
It is an outdated extension and sometimes works in an uncomplete way. But it is worth a try.

Built-in Edit>Find & Replace is limited to one paragraph contents. Therefore you can’t specify a search target spanning several paragraphs.

In fact, what you want is not to fix two paragraph marks in a row, but to eliminate empty paragraphs, i.e. void paragraphs.

For that:

  • enter ^$ in Find box. This pattern means: from paragraph start ^ to paragraph end $ with nothing in between.
  • leave Replace empty.
  • tick Regular expressions

Press Find Next to check the pattern is correct. Then press Replace All if you’re confident or Replace repetitively to process each occurrence one by one.

PS: when asking here, always mention OS name, exact LO version (not “latest”) and save format.

2 Likes

Using Regular Expressions in Text Searches