Sublime Forum

Make Find always go to next match

#1

When Find matches multiple items in a document, it seems to go automatically to the last modified passage. I am not sure exactly what the logic is here. But i want to make it so that it always goes to the next match in the file, relative to the current cursor position. I think this is similar to incremental search; but it needs to work with replace.

My use case is this. I’m working with a large file. I find a specific case that needs work. The issue is fixed by using a regex. But the regex matches many segments in the text. So instead of selecting the specific text that I need, it jumps somewhere else.

It doesn’t do this all the time; sometimes it stays where it is. But I have never been able to figure out what makes it stay and what makes it go! If I could have a setting to make it always go to the next match, or at least a clear explanation of the logic in how it works, I would be very grateful.

0 Likes

#2

In my experience, with “highlight matches” enabled, if I compose a regex that at some point doesn’t match the text I want (i.e. it ends up finding something further down the document), but I edit it so that it does, it still correctly prioritizes the closest match after where my caret was before I opened the find panel.

I even tried clicking somewhere in the document and explicitly pressing “Find”, but when I alter the regex again, it still begins from the original caret position, so I’m not sure what could be causing the behavior you describe. Maybe it is different when doing replacements, or maybe you have a plugin that is somehow interfering with the default behavior.

0 Likes

#3

Thanks for the response. I have “Highlight matches” enabled, and I don’t have any plugins.

But thanks to your hint, I have tried switching “Highlight matches” off, and now it works fine.

That’s been bugging me for literally years! I had been driven to such depths of despair that I even started using Geany instead of Sublime; so this is a real life saver. (Geany’s quite nice actually, but Sublime is nicer.)

I’m still not sure why highlighting matches should affect the position; but maybe it’s just one of those things.

0 Likes