In Visual Studio—my main squeeze for many years—I can press Ctrl+F to immediately search for the identifier or string that my text caret is touching, or else the currently selected text if I have a selection. I can press Ctrl+Shift+F to search the whole project, solution, or other file sets. I like this.
In Xcode 3.*—my main squeeze in recent years—I could press Cmd+Opt+F to immediately search for the currently selected text and Cmd+Opt+Shift+F (a bit of a handful, but workable), to search throughout the project. I liked this a bit less than the VS approach because I first had to select some text, then search for it, rather than the IDE automatically picking up the current identifier for me if I hadn't selected anything. But it was fine.
Now in Xcode 4 I notice that there is a Cmd+E shortcut that makes Xcode "Use Selection for Find." But it... well it sucks bad. All it does--apparently--is to copy the current selection and paste it into the find box. It doesn't show the find box, so if the find box isn't currently shown then Cmd+E has no visible effect. Cmd-E does not actually invoke the search--it only copies the text. So now searching for an identifier becomes a three step process: select the identifier, press Cmd+E, press Cmd+F (or Cmd+Shift+F for project-wide search).
IMO, Xcode 4's three-step process is worse than Xcode 3's two-step process, which is worse than Visual Studio's one-step process.
My question: In light of this falling UI efficiency along with recent international events, is the world just going downhill and soon all will end in a fiery apocalypse in which the few remaining humans will be forced to retype War and Peace each time they want to search for an identifier?
Once you hit CMD+Shift+F, look for Find > Reference > Containing right above the text box. Click on "Reference" and change it to "Text". This will search for every piece of text.
To find text in a file, open the file in the Xcode source editor and choose Find > Find from the menu bar. Xcode displays the Find bar and its search controls at the top of the file. Enter a search term. Xcode searches the file, highlights matches, and notes how many it finds.
ughoavgfhw offered the correct answer (above). Use Cmd+E on the selected text
to begin searching with that text. Then immediately type Cmd+Shift+F to search the whole project for all instances of the text hit enter.
This is quite quick, consistent, and sensible. It's not as immediate as Visual Studio's single-stroke Find/Find-in-Files—Xcode requires two strokes rather than one—but personally the extra step doesn't bother me.
Late to party but someone might benefit:
I use the free BetterTouchTool and define a custom shortcut for missing or awkward Xcode shortcuts. You can attach multiple actions to your custom shortcuts, I have assigned Cmd+E - Cmd+Shift+F - Enter to middle mouse button, it lets me search the selected text in workspace with a single click. You can assign the same actions to a keyboard shorcut though I like mouse buttons better for this task because I also do the text selection with mouse.
ps: BTT gives you the option to select in which application your shortcut will apply or you can make your custom shortcuts global, which I also find handy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With