ActiveState Community

Find previous selected

Posted by plynx on 2009-06-05 07:20

I'm confused by the presence of "find next selected" in the Komodo commands and no "find previous selected." I typically like to bind these commands to ctrl+shift+down arrow and up arrow, respectively, and find them immensely useful.

Is there a way I can make a "find previous selected" macro, or is there some other navigational feature I'm overlooking that I would be better served using?

dafi | Fri, 2009-06-05 09:19

take a look at all key bindable function

Preferences -> Editor -> Key Bindings and search 'find', you will see the "Find Previous" command

--
dafi
Enhance KomodoEdit with MoreKomodo

plynx | Sat, 2009-06-06 07:06

Thanks for answering, but "Find Previous" is not the same as "Find Previous Selected"

When you do Find Next or Find Previous, it goes by what was last in the Find dialog box. When you do Find Next Selected (and what I want in reverse), it goes by what is currently selected.

toddw | Sat, 2009-06-06 10:53

There is no command yet for find previous selected. I'd recommend filing an enhancement request for this:
http://bugs.activestate.com/enter_bug.cgi?product=Komodo

You can use a Komodo macro to implement a find previous selected, here is an example. Create a new macro in your Komodo toolbox, label it "Find Previous Selected" then paste in the following JavaScript code:

ko.commands.doCommand("cmd_findNextSelected");
ko.commands.doCommand("cmd_findPrevious");
ko.commands.doCommand("cmd_findPrevious");
ko.commands.doCommand("cmd_findNextSelected");
ko.commands.doCommand("cmd_findPrevious");
ko.commands.doCommand("cmd_findPrevious");

You can then assign a keybinding to your macro "ctrl+shift+up" and use it that way.

Cheers,
Todd

plynx | Sat, 2009-06-06 13:52

Thank you! This fills the find buffer with the current selected item using find next selected and then backtracks twice as a workaround. It's quite a bit slower than the other command, but it does work.

Is there any way to load the currently selected text directly into the find buffer using a macro? Then I can just immediately do a find previous, and that would solve the speed issue, I imagine.

Thanks again!

toddw | Sat, 2009-06-06 17:23

Sure it's possible, you can see the find_next_selected command is implemented here:
http://grok.openkomodo.com/source/xref/openkomodo/trunk/src/chrome/komod...

I'd imagine you'd simply do the same thing though you'd change the search direction:
findSvc.options.searchBackward = true;
before calling "Find_FindNext".

Cheers,
Todd

plynx | Sat, 2009-06-06 17:38

I copied that code into my macro and just replaced the false with true like you suggested... worked like a charm! Thanks so much!

What an awesome editor