Incremental Search?


#1

Are there plans for incremental search?

My primary use case is for quickly moving around in a document (so reverse incremental search is needed to). Or is there some feature that the Atom designers use for this purpose?


Instant, incremental find
Instant, incremental find
#4

I also use it for the same thing, and to be honest, I like to use it in Vim to build my regex searches, since I can see what I’m matching as I write the regex. I would find this very useful and would like to see it in Atom.


#5

Given the close modeling on SublimeText for basic design, I’m really surprised that Atom doesn’t yet have incremental search out of the box. This is the core feature I miss most from [any other reasonable editor].


#6

out of curiosity, and for my understanding: what exactly is incremental search to you?

My interpretation right now would be “something like Ctrl+K in eclipse” (which i use ALL THE TIME). For those not familiar with eclipse, Ctrl+K works like this:

  • Whatever is selected RIGHT NOW will be searched. If you have “food” highlighted/selected, one push of Ctrl+K will jump to the next occurrence of “food” in the same file.
  • When nothing is selected, Ctrl+K will search for the last thing that had been searched with Ctrl+K (sounds weird, but is actually extremely useful, for example when you’re jumping through a file, renaming a variable or fixing documentation).
  • Ctrl+K and Ctrl+F are not related as far as i know, which is neat because that way (in eclipse) you get to use 2 distinct searches for free. Let’s say you have two things you need to go over in a file. Put one in the Ctrl+F Searchbox, and search the other via Ctrl+K. You can now easily jump forward with either of them.

#7

In my case, I come from years of emacs and recently Sublime Text. Emacs’ version was more sophisticated, but they’ve had 30 years to tweak it :smile:

In emacs, the key is “ctrl-s”. Pressing it once brings up the incremental search buffer. When the buffer is up, pressing ctrl-s again will automatically reuse the previous search. Ctrl-n and ctrl-p (next/previous) cycle through the last 30 or so searches, we is very handy when you are searching through logs and large files for a couple of things. Typing immediately jumps to the next entry.

Pressing enter is not required, so enter is used to exit isearch leaving the cursor at the last search. Esc exits isearch and returns to the initial cursor position when isearch started. This is something missing from current search since I can’t “commit vs cancel”.

Ctrl-r is the same thing but in the opposite direction. You can mix ctrl-s and ctrl-r on the fly and it jumps forwards and backwards.

There are other keys for toggling case-sensitivity, regexp, slurping the next word from the buffer, etc.

One very important aspect of this is that Atom designers will need to look at soon is to try not to assign every possible key so early in the product. By using only a couple of keys (ctrl-s and ctrl-r) to start the search, having them and other keys behave differently when the isearch is already underway would be great. For example, look at how many keys the find package has allocated.


#8

Incremental search is where you can hit a key (cmd-i in my case) and start typing. Every keystroke will find what you have typed so far, highlighting all matches and selecting the first one. This means that if you type something that doesn’t exist you will still move to and see the longest partial match. At any point you can hit the key combination again and it will move the selected match to the next match.


#9

FYI, a shameless plug. My package find-selection does what ctrl-k in eclipse does. Well almost. Until I read your post I didn’t know what to do when there is no selection. Using the old search sounds really useful.

I will update find-selection to add the empty selection trick.


#10

FWIW, find-selection v0.13.1 now matches ctrl-k behavior.


#11

indeed! Thanks for the tip! (and the plugin itself, of course :wink: )


#12

Edit: Renamed isearch to incremental-search

I’ve published the incremental-search package.


#13

After it jumps to my target I esc to hide the search box and I end up coming back to the begining.
Can you add an option that it stays in the new location after esc?


#14

I believe the answer is to press Enter instead of Esc. Enter to confirm, escape to cancel.

Also, I’m not using Atom anymore and am looking for someone to take over any of my projects like incremental-search. Any takers?


#15

For others who come across this, I just discovered the scrollToResultOnLiveSearch setting in the core find-and-replace package. This is set to false by default. When set to true, it gives you something pretty close to incremental search in other editors.

It’s a fair bit slower than incremental search in Sublime, but this has made Atom much more usable for me.


How can I go to the 'found' line whenever I search?