Published incremental-search, an incremental search package


#1

Edit: Renamed isearch package to incremental-search

I’ve published the incremental-search package which provides incremental search designed for fast navigation.

The default keys for OS X are cmd-i (incremental-search-forward) and shift-cmd-i (ncremental-isearch-backward). I haven’t set Windows and Linux keys, but I would assume ctrl-i and shift-ctrl-i would be a good choice. (If you are a long time emacs, readline, bash, etc. user, you may want to map them to ctrl-s and ctrl-r.)


#2

I hate to say it, man, but someone has been just a smidgen faster on this one:

Seriously, this finished last weekend I think. But maybe it’ll be interesting if one does have an advantage over the other?


#3

Actually they are not even remotely the same feature. Incremental search is something completely different and if you’ve never tried it, give it a shot. In fact, you may want to find some articles on “incremental search” for other editors to see how people use it.

A selection type search only works if you are already setting on the text you want to find. That can be useful but isn’t as flexible. I’ve opened some enhancement issues that will help with finding the current selection also, but incremental search is fundamentally different. (In particular I need to have isearch seed the search with the current selection and provide a “slurp” like emacs which is more flexible that Atom’s slurp once.)


#4

I have not the faintest idea what you just said. But I suppose I’ll have to try your package to find out!
And so I shall.


#5

As the author of find-selection I’d like to agree that these are different functions for different usage cases. Find-selection makes it easier to search for already selected items and isearch makes it easier when you need to type it in.

I am eager to try out isearch. I have missed incremental search in atom.


#6

Thanks for working on this! I’ve been hoping for an incremental search package. However I installed it and I am seeing some problems — potentially related to the Autocomplete Plus package. As I start typing in the i-search input and text is highlighted in the editor the focus suddenly jumps out of the i-search input and I end up overtyping the selection in the editor. This may or may not be related to Autocomplete Plus showing completions as i-search results are highlighted in the editor. Please let me know if you need any further details from me.


#7

Here’s a screen capture to illustrate the problem:


#8

Maybe I missed something important, but isn’t it exactly what the bundled find and replace package does?


#9

No, it really isn’t. I don’t know what platform you are running, but if you are on a Mac and have TextMate handy compare ctrl+s (incremental search) with cmd+f (find). They behave differently. Or again, if you have Emacs (any platform) compare alt-x search-forward with ctrl+s.


#10

Incremental search is like what Chrome does when searching. You can type “fix” and it will highlight all copies of “fix” on the page … perhaps also including “fixForBug” and “fixation” and “fixination”. You look at the results and decide you want only “fixForBug”, so you type “For” and all instances of “fixForBug” are highlighted … but maybe “fixForm” is also selected. So then you type “B” and only instances of “fixForBug” are highlighted. Then you can click the next button until you get to the instance of “fixForBug” that you’re actually looking for.


#11

Renamed to incremental-search

One of the first issues brought up was that it was difficult to find. Since I haven’t seen keyword support is working yet I’ve renamed the package to incremental-search.

Please uninstall isearch and install incremental-search.

Thank you.


#12

Regarding the autocomplete problem, I don’t think it is an incremental-search problem per se. There are only two things it is doing that are unusual: selecting the current result and creating markers & decorations. It really must be the fact that the selection is moving.

I’ll take a look at autocomplete and see if there isn’t an easy workaround. It’s possible I could add an option to not move the physical selection or perhaps to move the cursor but not select anything. I really think the autocomplete package shouldn’t be popping up just because the selection is changing.


#13

Thanks. Just an FYI, it’s the popular Autocomplete Plus package, not the Autocomplete package that ships with Atom.


#14

After looking at it, I opened an issue with the Autocomplete Plus package:

We’ll see if they have any suggestions for making the work better together.


#15

Regarding Autocomplete, I got another request so I made a new version to fix it instead of waiting for an update from Autocomplete Plus. There will probably be other packages that react to cursor / selection changes.

Version 3.0.0 no longer moves the cursor until a search is committed - displaying results and moving through them uses only markers / decorations and scrolling. Let me know if that works. If not, please re-open issue #9


#16

That is working much better for me now. Thank you.


#17

Glad to hear it is working.

By the way, you may notice that the current result is not as noticeable anymore since it is not also selected. I added an Overriding Styles to the docs to help with this. Personally, I highlight the current result with a red border like the example and find it makes a big difference. Perhaps I should make that the default instead of trying to match find-and-replace.


#18

Oh, useful, thanks!

shift-cmd-i toggle dev-tools

In keymap.cson:

'alt-right': 'incremental-search:forward'
'alt-left': 'incremental-search:backward'

Now, works well for me :slight_smile:


#19

Feature request from an old-time Emacs user: Implement the ctrl-w functionality. This works as if the remaining letters of the current word were typed.

Say I type cmd-i followed by fo, and I happen to land on the word foobar. Then hitting ctrl-w would be equivalent to typing obar, or equivalent to changing the search string from fo to foobar.


#20

Agreed: I have Issue #6 for this and have a local branch. I hope to have this released in about a week.

I’m using cmd-e since it is similar to find-and-replace’s “use selection”, but an emacs user will have not issues changing key bindings. :slight_smile: