Sublime Forum

Find in selection behavior

#1

I find that (in the latest nightly build, but I also experienced it earlier) the “in selection” button of the find panel sometimes behaves oddly. I managed to make this reproducible:

  1. Open a new file.
  2. Enter “test”
  3. Open the Find panel (cmd+f, “in selection” button is deselected).
  4. Search for “e” -> highlights the letter e
  5. Select the whole word “test” and activate the “in selection” button (or press cmd+f, this will activate the button, too (correctly))
  6. hit find again-> “unable to find “e” in selection”

Overall I would highly appreciate it if there were some visual indication what the “current selection” refers to. When you select a region, press cmd+f to find something in the region, each match will be highlighted as a selection (which is absolutely fine) but then the indication of the area that is being searched is gone.

This is sometimes especially weird when you just have been searching something within a selection and now want to search something different, and–by mistake–have the “in selection” box still activated, there is no visual clue that the text is only found in a certain region.

Any thoughts by other people?

1 Like

Nightly Build 2199
#2

I can’t quite believe that nobody ever encounters these sort of problems?

0 Likes

#3

“find in selection” confuses me too.
when my selection spans across multiple lines and i hit cmd+f, find in selection options is activated.
i expect this to be true for single line selection, but it’s not.
i find this is incosisten bahaviour.
if i have selection before initiating find i’d expect that option to be turned on.
is this by design?
is there a way to add keyboard shortcut to toggle ‘find in selection’, and some of the other find options as well?

0 Likes

#4

Like @hubert, I expected the behavior of ‘find in selection’ to automatically respond to whatever the selection is (or becomes while the find/replace toolbar is open). I imagine that the reason it requires one to make the selection and then Ctrl+F to ‘reset’ what the ‘selection’ is has to do with the problem of selecting found items. I’ve noticed in other editors that they will select found text and then change what ‘selection’ means to be just the text they selected for you (rather than the larger subset of selected text you started with). One way to get around this problem would be to have the user select text and then trigger an action (e.g. Ctrl+F) in order to ‘set’ what the ‘selection’ is. This appears to be what the developer of Sublime has done.

There are a few usability issues with this choice. For one, it seems like ‘find in selection’ is broken when the user makes a new selection and Sublime can’t find anything within it. To fix this, the ‘selection’ would have to dynamically change while the find/replace toolbar is open (but only by the user; changing the selection by finding a term would be bad).

The second problem with the current setup is that Ctrl+H (for find/replace) does not trigger a reset of the ‘selection’. Right now, one has to do a Ctrl+F and then a Ctrl+H to reset the selection in order to do find/replace.

0 Likes

#5

I’m also frustrated by what seems to be exactly what @hubert describes, using the latest ST3 beta (build 3059 stable channel)

0 Likes

#6

I’m on build 3059 (linux, on ubuntu 12.04), and have had to do the replace in selection action twice every time I’ve wanted to do a search/replace in a selection of text.

My process:

  • ctrl+h (bring up search and replace dialog, and if anything is selected it gets deselected…)
  • type the text to find, and the text to replace it with
  • click the “in selection” button
  • select my text
  • click “replace all”

Nothing gets replaced, even though there are text matches in the selection. So Then I repeat the process:

-ctrl+h (my text selection is deselected, but my search and replace texts are still there)
click the “in selection” button again
select the text again
click “replace all” again

The second time it works…

0 Likes

Expand selection to everything between < and >
#7

This setting should help you.

 "auto_find_in_selection": false
0 Likes

#8

Thank you very much, s7dhansh. That worked fine. :smile:

0 Likes

#9

This is still broken! Steps to reproduce:

  1. Press ctrl+f
  2. Select line of text to search from.
  3. Change search query in form on bottom of Sublime window.
  4. Press “Find in Selection” button.
  5. Press Find All.

The resulting message is
Unable to find ___ in selection

0 Likes

#10

it’s not broken, just swap your steps 1 and 2 around

0 Likes

#11

+1 for find-in-selection is confusing! Also, I find it very error-prone. Sometimes I do a quick search and replace, trying to remove, say, quotes from my current selection with a regexp - only to find later I’ve removed all quotes from the entire file. I just did this today!

My vote for find-in-selection behavior: KISS!

  • Eliminate the feature entirely. If there is a selection, always and only do the search in the selection.
  • When search is up, preview BOTH the current selection AND the current search results with different highlight styles.
  • If the user changes the selection while search is up - update the search-area. The order of show/hide search and make-selection should have no bearing on the search result. Always use the current selection area - no matter if the search-window was or was-not up.

This would simplify the interface (removes a button). It makes everything more clear by eliminating a bunch of edge cases that confuse people. Last, it would be less prone to accidental whole-file search-and-replace.

All without losing any functionality - just de-select if you want to search the whole file.

Thanks! I still love Sublime text after all these years. I’d happily pay more money for regular updates and UX streamlining (ahem, like my suggestion above). I spend all day, every day using this one piece of software. You guys charge way too little for such an important, professional tool.

3 Likes

#12

This would be a great upgrade. Can we hope this gets fixed one day? I moved from Notepad++ ot ST yesterday, and I already find this find-in-selection “feature” really annoying… When the user tries to Ctrl+H a selection, the selection should stay unless the user changes it, period: it"s just allowing the user to do whatever he wants to do.

0 Likes

#13

Having a single word selected would search within that word, that’s weird man.

The find_selected_text setting would be totally broken as your entire “search selection” would end up in the find input field, and if that takes many lines the find panel becomes gigantic.

Also, imagine you have a search selection of a thousand lines. Then you search for something within it - now selecting anything (to say, copy some text) would change the find selection too and you can’t continue your search without reselecting the huge selection…

0 Likes

#14

Sorry to reopen the case but I think I finally found my solution to this issue (cause it’s a big one to me) :

1- Select the zone I want to select in
2- hit Ctrl+F (it opens the search panel with exactly the text I selected as the first research)
3- hit the “in-text” button (in actually highlights the whole text to says the whole text has been “found” and can be selecte
4- actually click in the search bar, and type your actuall research (will go inside the previous selection)

This is the fastest way to do it I guess, because my previous “solution” was rmmoul’s solution, and do things twice can be kind of frustrating.

Your other solutions didn’t really work with me.

Peace :wink:

laagjet

0 Likes

#15

If you’d like to add a shortcut for the in selection option when performing a find operation, see my comment in the following thread (click the “Find in selection keyboard shortcut” link to see the full, properly-fornatted text of the comment).

This will also work to toggle the button when searching within multiple single-line or text string selections.

0 Likes