App icon 1Writer

Find (repeat search)

Shared by Mason

A work around to be able to search repeatedly for same term

Script

//Put what you want to search for repeatedly between the quotes on next line. You will have to edit this action each time you want to change tour search term.
var find = "SEARCH TERM GOES HERE";

find = find.toLowerCase();
var text = editor.getText().toLowerCase();
var srange = editor.getSelectedRange();
var index = text.indexOf(find, srange[0]);
if (index == -1 && srange[0] > 0) {
    index = text.indexOf(find);
}
if (index != -1) {
    editor.setSelectedRange(index, index + find.length);
}
else {
    ui.hudError('Not found');
}