Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Monday, March 9, 2020 at 20:19


Advantage of word processor in computing compared to typewriter machine in real life is that user can find a word far more quicker in a long text document. User can find anything by just one touch and find further by touching once again. Not only that, the most excellent advantage is that the word found can be replaced in entire document as user wishes. In LibreOffice Writer, these two advantages are available in Find & Replace feature (shortcut: Ctrl+H). You can find a word, a phrase, a sentence, even a pattern of text matched you wish. Later, you have two more options, first as words found all selected you can reformat them, and second you can replace them. This article will help you practice that with Writer. Happy learning!


Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.


# Index
- Find
- Find next and find previous
- Find and select all
- Find and replace
- Find and replace with pattern
- Find and replace with format

# How the dialogs look like
- Here is Find dialog (toolbar):


There are 8 buttons there: Find Previous, Find Next, Find All, Match Case, Find & Replace, Navigate by, Previous Element, and Next Element.

- Here is Find & Replace dialog:

There are 9 buttons: Find Next, Find All, Replace, Replace All, Match Case, Whole Word Only, Other Options, Help, and Close.

- Here is Other Options section when opened:

There are additional 12 buttons: Current Selection Only, Regular expressions, Similarity search, Similarities, Ignote diacritics CTL, Backwards, Searh for Paragraph Styles, Commends, Ignore kashida CTL, Attributes, Format, and No Format.


# Find (Ctrl+F)
- Go to menubar Edit > Find
- Appears a toolbar Find on bottom
- To close this toolbar, click the cross button

To find, type a keyword and press Enter. If a keyword found, that one keyword will be selected on document.

 

# Find next and find previous (Ctrl+F)
To find same keyword on other places, press Enter to find next, or press Shift+Enter to find previous. Alternatively, you can click Previous or Next arrows on the toolbar instead.


# Find and Replace (Ctrl+H)
To find and replace within whole document, type a keyword under Search for and type another keyword under Replace With and finally click Replace All button. The result is all matched text in document changed with the new keyword.



Example: replacing all occurrences of the word "memori" with "penyimpanan" in Indonesian

# Find and Replace only in selected text, not whole document
- Select a certain portion of text, for example a paragraph only
- Ctrl+H, appears Find & Replace dialog
- Type Search for a keyword, and type Replace with another keyword
- Click Replace All
- All matched text in selected portion of text changed into another keyword
- The rest unselected text within document left unchanged

This replacement is used if you only want changes applied to a certain portion of text not whole document. You can combine this with regex and formatting. See next sections.

# Find and Replace with Regular Expression (Regex)
- Ctrl+H
- Click other options
- Make sure Regular Expression is checked (activated)
- Make sure Match case is checked (activated)
- Type Search for a regex keyword, but do not fill Replace with
- Click Find All
- Do not click Replace All
- All matched text found and selected
- To replace, type keyword in Replace with and click Replace All

Many times we need to find some text with a certain pattern (text with similar senses but different typings) such as selecting ubuntu1, ubuntu2, ubuntu3, until ubuntu100. The problem is it is wasting time either way we select manually one by one, or simply Find using "ubuntu" keyword alone that leave the numbering. Same thing more or less applied to other examples. The secret is, we can Find text by using pattern, called Regular Expression, that will match with actual texts. Example above is Findable with pattern ubuntu[0-9].* that match ubuntu1 until ubuntu100. There are many other patterns (regexes) available to use. This example is just one among many.



Examples of other interesting regexes you can try:
\b[a-z]{3}\b to find all words, any word, consisted of 3 characters
\b[0-9]]{3}\b to find all numbers, any number, consisted of 3 numbers
^$ to find blank lines
^ubuntu$ to find lines consisted of ubuntu text only
 # Find with format

- Ctrl+H
- Put cursor at Search for
- Click Format..., appears Format (search) dialog and here determine font, size, mode, etc.
- Determined formatting appears under Search for box, e.g. "Italic normal" or "Bold normal"
- Click Find All
- All text with determined formatting selected

Writer features advanced searching text with a certain formatting. For example, you can easily find words which are italicized or made bold or even combination of both. Once found, they are selected, you can either replace them or simply reformat them with other formatting such as coloring or numbering.


Example finding all occurrences of italicized words


# Find and Replace with Format

- Ctrl+H
- Do find with format
- Put cursor at Replace with
- Type keyword
- Click Format..., appears a Format (replace) dialog with Font selections
- Set font choice, click OK
- Click Replace all
- All text with matched formatting replaced



This is not changing the text (empty boxes) but only the formattings for example those which originally Italicized to be Bold or vice versa.

Example replacing (reformatting) all italicized words found before with same words but bold

# Find and Replace with Format with Text

- Ctrl+H
- Do find and replace with format, but determine keyword under Search for and determine keyword under Replace with
- Click Replace All
- All text with matched formatting changed into new text and new formatting


(Example changing all occurrences of the word "yang" bold with "which" italic)

Summary

Up to this point you learned points important in Finding and Replacing text in Writer. However, several other things are not covered in this article such as doing that against Paragraph Styles (not merely formatting) and Complex Text Language like Arabic. I wish with examples in this article you can discover yourself more things here especially about regex. See you next time. Enjoy writing!

Further Readings

More Regular Expressions


This article is licensed under CC BY-SA 3.0.