Find & replace
Search the text you are writing and replace what you find, with match case, whole words, regular expressions and your recent searches.
Plenty of apps have no search of their own, or one that only finds. Find & replace works in any text field: it searches what you have written, steps through the matches, and replaces one or all of them.
Opening it
Section titled “Opening it”Tap Find & replace on the toolbar, or in the toolbox if it isn’t pinned (see the toolbar). Tap it again to close it. If you have a few words selected on one line, they become the search, the way Ctrl+F works on a computer. Otherwise it opens empty.
The same panel opens from the selection actions bar’s Replace chip, already holding what you selected.
Password fields can’t be searched; the tool says so and opens nothing.
Searching
Section titled “Searching”The panel has two fields, Find and Replace with. Tap one and type into it; the keys go to the panel, not to the app. While one of them is focused, its word suggestions sit in the row above the keys. With the toolbar on a row of its own, the suggestion strip above the panel gives up its row while the panel is open, so there is only one strip, and the toolbar row stays open. The count beside the arrows says which match you are on and how many there are (3 of 12). ‹ and › step through them and wrap round at the ends. Enter in the Find field goes to the next match. The × at the end of a field empties it in one tap.
The current match is selected in the field itself, and also shown in its line at the bottom of the panel with the match marked, so you can see it even when the keyboard covers that part of the text.
The field is read again on every step. Some editors, code editors and notes apps in a web page among them, only draw the part of a long text that is on screen, so the text changes under the panel as it jumps from match to match. After selecting a match the keyboard also reads back what ended up selected. If it isn’t the match, which happens in editors that count their text differently from the way they hand it over, the keyboard looks for the match close by and selects it there.
Four toggles change how the search reads and what a replacement writes:
- Aa matches case.
- [ab] matches whole words only, in any script.
- .* reads the Find field as a regular expression.
$1in the replacement stands for the first group. A pattern that isn’t valid says so, and one that takes too long on the text is stopped, as below. In the replacement,\nis a line break and\ta tab. - AB preserves case: each replacement takes the case of the text it replaces, so replacing
catwithdogturnsCatintoDogandCATintoDOG. Mixed case such asiPhoneis replaced as you typed it.
Patterns that take too long
Section titled “Patterns that take too long”A search with a pattern gets one second. Most need a small part of that, even in a long text, and typing another key stops the search already running. If the second runs out, the panel says The pattern takes too long on this text and shows no matches. It says the same for a pattern with very large counts, such as x{0,9000}, which is too big to run. A plain search has no limit and doesn’t need one.
Some patterns have a huge number of ways to fit the same text: (a+)+b on a long run of the letter a, for instance. These now run normally, because the search never goes back to a dead end it has already tried. The exception is a pattern with a backreference such as \1. Everyday ones, such as \b(\w+) \1\b for doubled words, are quick, but a complicated one can use up its second.
When a replacement uses a group, such as $1, the keyboard matches the pattern again to fill it in. That gets a fifth of a second in all. If it isn’t enough, the keyboard shows the same message and changes nothing.
Up to 0.6.8rc1 the limit on a search did not work on a phone, and filling in a group had none.
Replacing
Section titled “Replacing”Replace swaps the current match and moves on to the next one. Enter in the Replace with field does the same. All replaces every match at once, and Undo takes it back in one go too. A field that doesn’t report where its text is (a few web views) still lets you find, but not replace in place.
Recent searches
Section titled “Recent searches”Opened from the toolbar with nothing selected, the panel starts on your last search and your last replacement, both drawn selected the way a text field shows selected text. The first key you press types over the field it lands in, so a new search needs no clearing. To search for the same thing again, step to a match.
While the Find field is empty, or still holds last time’s search, the bottom of the panel offers your last ten searches. Tap one to search for it again, or Clear to forget them. A search is remembered once you use it, by stepping to a match or replacing, not while you type it.
Nothing is remembered in incognito, in a field that asks not to be learned from, or in a password field. To stop remembering searches altogether, or to clear them from Settings:
WM Keyboard Tools Find & replace Remember searchesFind and replace is the Find and replace bundle on Extensions. Off there, the tool leaves the toolbar, the toolbox and the Tools list until the bundle is switched back on.
