Sublime Forum

Search not working

#1

Search isn’t working in my Mac version of SublimeText 2.

If I enter a search term which appears in a document (e.g. “foo”) I get a message at the bottom left of the application window that says “[x=number] matches; Unable to find foo”.

I uninstalled and reinstalled the program. What else might I try?

0 Likes

#2

More bizarre behavior: some text searches work, but when they do the “Find Prev” button finds the next occurrence of the search term, and the “Find” button finds the previous occurrence.

0 Likes

#3

I’m having the same problem. Version 2.0.1, Build 2217.

0 Likes

#4

It sounds like you have the ‘Reverse’ button checked on the Find panel.

0 Likes

#5

About the first issue: You are probably searching only in the current selection.

0 Likes

#6

Problem solved: I had the “Whole word (Alt+W)” option selected, after toggling it to off my searches started working.

Thanks jps for pointing me in the right direction.

1 Like

#7

Hi,

I had the same issue and finally found the “wrap” button to be the culprit. When it’s turned off, find stops at the end of the file.

Cheers!

1 Like

#8

The “Wrap” button was the problem for me too. I has to be on (“pressed”). When I did that, searching returned to it’s normal behaviour.

1 Like

#9

Funny @jps how instead I had the “Reverse” button unchecked and the search did not work, checking it made the search work so thank you!!
Oh, the search works in half, I still get “unable to find X” message, but at least I see the results highlighted in the document.

0 Likes

#10

I have search problems too, but different from the above. When I “Find in Files…” across my project, a particular folder is getting excluded, even though I’ve commented out any binary_file_pattern or similar settings in the project. It shows the correct number of files to search through, it just returns no results for any of the files that are there even for searches that I can independently confirm would return a result. This behavior is new to Sublime Text 4.

When I perform the search, it is in a subfolder of the project (foo/bar). If I move the search to just bar, the search returns the results I expect (but of course, along with all the other similar results in subdirectories of foo).

EDIT: Trying this later, if I put a forward slash at the end of the “find in” directive (i.e., foo/bar/), it returns the expected results. This is bizarre, because I don’t need the trailing slash when I search the parent directory (i.e., foo works just as well as foo/). I was wrong about it searching the right number of files, though, adding the trailing slash increases the number of files it searches for whatever reason (not from 0 to ~900ish, but from ~300ish to ~900ish). What is happening here to limit where the search looks?

0 Likes

#11

There is now documentation on file patterns and how they’re used in various settings and in Find in Files; it sounds like perhaps you’re running into this (the latter part of which is new for ST4):

  • If the pattern ends in / it will be treated as a directory pattern, and will match both a directory with that name and [4.0] any contained files or subdirectories
0 Likes

#12

That’s interesting, but I’m having trouble understanding why it’s producing different behavior in this situation. The description in the documentation there makes it sound like the non-slash-trailing version of the find string also recurses subdirectories, and indeed in my case, the number of files searched is much too high for it to just be searching files within folders that match */foo/bar, but not subfolders of those folders (but, yes, too low to actually be all the files that are subfolders of */foo/bar/). I don’t know how to resolve that contradiction.

Also, an aside., in windows at least, the // seems to flatly not work. It seems to get mutated to \\ and then treated as an absolute file path (i.e., //bar, rather than translating to /foo/bar when foo is project root, becomes \\bar and then fails to find anything because \\bar isn’t an absolute path on the mount containing the project)/

0 Likes