5

I want to have a keyboard shortcut for “Find Next” and “Find Previous” (or “Search Next” and “Search Previous”, or “Repeat Search Forward” and “Repeat Search Backward” or whatever you want to call it) that works all the time.

The shortcuts F3 and Shift+F3 only work when the cursor is inside the search bar. The shortcut Ctrl+Shift+F (“Repeat Search”) only works in one direction, but I often want to go back to the previous occurrence. So neither of these work for me.

There is no “search previous” command, but I'm hoping to define one, and an actual “search next” to go with it, as macros and bind a key to those macros. Seems doable. I tried recording a macro around a call to “Repeat Search”, which sets up some parameters and calls .uno:RepeatSearch, but I don't know how to make it go in a specific direction, if it's at all possible. I also tried recording a macro around pressing the ⇩ button in the search bar, but that hard-coded the search string, and I don't know how to make it use the parameters of the previous search.

How can I bind keys to “Find Next” and “Find Previous”, whether through a macro or otherwise? I need this at least in LibreOffice 4.2.8.2 on Linux.

1

Use .uno:ExecuteSearch (assuming that is what the recorder gave you), but instead of a hard-coded search string, input the value like this:

Global SearchString
Sub doSearch
    SearchString = InputBox("Search string:", "Search", "")
    ' Put the .uno:ExecuteSearch code here.
End Sub

Then change the hard-coded search string to use this variable:

args1(11).Name = "SearchItem.SearchString"
args1(11).Value = SearchString

Now for repeat searches, create two additional macros, one for each direction. Set "SearchItem.Backward" to true or false. Instead of another InputBox, use the SearchString variable that we stored earlier.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.