An alternative search tool for LibreOffice Writer
AltSearch
AltSearch offers extended functionality to LibreOffice Write's default find and replace tools, making it ideal for editing and formatting longer documents.
Few features in a word processor are less glamorous than a search tool. That is, until you do some intensive editing, especially if your revisions include reformatting. Then you will be thankful for a full-featured tool. In the case of LibreOffice Writer, the available tools are barely adequate, which is why I recommend the Alternative Find & Replace for Writer extension, also known as AltSearch [1].
Like all LibreOffice extensions, AltSearch is easily installed. Just download it from the LibreOffice extension site, and open Tools | Extension Manager. The next time you start Writer, AltSearch appears as a menu item, as well as an icon with green binoculars in the upper left corner of the toolbar.
You can understand the need for AltSearch by examining the default search tools in Writer. Edit | Find is a simple field similar to the ones found in many web browsers. It is suitable for finding words and phrases, but its options are strictly limited. You can search backward or forward from your present location in a document, find all, or match case – and that's all (Figure 1).
Edit | Find & Replace is more versatile, but it, too, is relatively limited. It can match case or search for whole words only. It has several additional features, such as support for regular expressions, similarity, and searches on a half-dozen paragraph styles, which make it more useful than Find – although you must be careful not to replace the Find field's contents with nothing if you use the tool just to search (Figure 2).
Another default tool, Navigator, which you open from the sidebar, allows searching by any object in the document, most usefully by six paragraph style headings, and even lets you reposition text below the headings without cutting and pasting (Figure 3) – but that is all. All three default tools are focused on finding and have limited power to edit.
By contrast, AltSearch offers more options (Figure 4). Admittedly, it suffers from some misspellings in the menus and is awkward to use. In particular, the menus are so long that it is best to position the window as close to the upper left corner of the screen as possible. However, most of the menu items include online help, and AltSearch's capabilities make the inconvenience worth enduring.
To start with, AltSearch's main window is better organized than Writer's default tools, with much of the complexity hidden. You can easily replace the default tools with AltSearch without delving into its complexities. But if you do take a closer look at AltSearch, you will find several important improvements.
For example, although Find supports standard regular expressions, it leaves the user to decide which ones to use. In comparison, AltSearch offers a selection window that includes custom expressions for formatting, such as custom hyphens and non-breaking dashes (Figure 5).
In addition, AltSearch offers a list of extended regular expressions (Figure 6) that, among other things, allows searches for most of the objects displayed in Navigator, including images, tables, frames, and cross references – a combination of features so basic I'm surprised that Writer did not do the same years ago. Other extended regular expressions include hyperlinks, text inside parentheses, and HTML tags.
Similarly, while the default tools only support basic paragraph styles, AltSearch's properties not only support character and list styles, but they can search on any of these styles used in the document rather than a basic few (Figure 7). Moreover, should these choices be overwhelming, you can run AltSearch on the basis of the text you select with the cursor. All these options greatly increase the chance of pinpointing a search item quickly, which is especially welcome in longer documents.
These options are not just useful in searches. They can also be useful in turning AltSearch into the desktop equivalent of the sed
command. For example, if you save a Writer document that uses styles into text format, the conversion eliminates the indentation of a new paragraph, as well as any space between paragraphs. Adding spaces between paragraphs manually is tedious, but with AltSearch you can search for paragraph breaks with /p and replace them with a paragraph break and an empty new line (/p/n), preparing the text version of the document within seconds. If you want the extra space only in a list style, you can specify the style as well. In much the same way, you can easily remove non-breaking spaces or hyphens by replacing them with nothing and find a character string at the start (/<) or end of a word (/>).
In addition, AltSearch can perform a search or a replace that contains more than one paragraph, or it can define a start and end point for a search. Both search and replace can be added from the clipboard, which is particularly useful with a clipboard that supports multiple entries. Styles can be replaced with another of the same kind, and objects can be renamed for easier navigation.
Perhaps AltSearch's most important single feature is the ability to do multiple searches via a batch file. The Batch manager opens with a list of some basic editing tasks, ranging from converting to a cleaner version of HTML than is available in Writer, converting date formats, or writing all of one kind of object to a new file (Figure 8). However, these are only samples of tasks that you can add to a batch file. From the Batch manager window, you can open the text editor of your choice and construct files that perform as many functions as you choose. When completed, a batch file can be executed and saved for later use. This function is especially useful in a longer project such as a book or thesis, where you might have many files that need to be edited in the same way because they will eventually be combined into a single work.
Conclusion
All this functionality takes a while to learn. Online help [2] exists, but it is more than a decade old and only marginally more detailed than the help built into the interface. For that matter, AltSearch itself seems not to have had a release for at least as long. So far, AltSearch continues to work, but a time may come when the latest LibreOffice release no longer supports it. If that ever happens, it would be a crippling blow to Writer's functionality, not just for search and replace but for serious editing as well. AltSearch is an extension that, like others before it, deserves to be a default part of the LibreOffice code. In fact, maybe someday, a version will be released for LibreOffice Calc as well.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
There's a New Open Source Terminal App in Town
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.