Some "Find and Replace" questions

Hi, I have a few basic technical questions about using “Find and Replace” in LibreOffice:

  1. Is it possible to delete all text in a document that use a specific character format (like font size and/or bold)? How do you do it?

  2. When doing Find and Replace, how to you search for characters that follow or are followed by a carriage return?

  3. When doing Find and Replace, how do you insert a carriage return before or after certain characters?

If anyone knows, thanks!

1. Character format?

There are two ways. First, using the CTRL-H dialog to get the “Find and Replace” window, then choose “Format”, and select the attributes you want from the next window. You might need to toggle-on the “Other Options” drop-down to get these buttons:

Your other option is to use the “Properties” option in the very useful LibreOffice extension, Alternative Find & Replace (you’ll need to install it, of course):

If you search AskLibO for “alternative find & replace”, you’ll find quite a few Q&As dealing with it. Very useful!

2. Characters following return?

You need to use the “Regular expressions” option with CTRL-H; you might need to toggle the “Other Options” drop-down to see it (see the first pic, above).

My (still) favourite resource for this is the OpenOffice wiki on Regex which is still applicable to LibO Writer. (But see also the LibO regex help, and the LibO Find & Replace help.)

For characters that follow a return (i.e., first characters of next paragraph), search like this (assuming you’re looking for “cat”):

^cat

That ^ signals “match at beginning”. To get “cat” followed by a return, search for:

cat$

and $ signals “match at the end”. (So searching for ^$ should find you all “empty” paragraphs.)

3. Insert return?

Using the “Regular expressions” option, search for cat, and then for “Replace with”, use cat\n, and the \n will add the “new line” or ¶ for you. (Don’t forget to uncheck “Regular expressions” when you’re done, or you may be mystified next time you search for something, forgetting that you’re using regex! Been there, done that.)

Also, do look at other LibO find-and-replace Q&As for plenty more of value. Hope this helps for a start!