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
-
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.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.