Search code examples
xcodesearchfindxcode4

Keyboard shortcut to find the currently selected text in Xcode 4


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?


Solution

  • 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.