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?
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.
For me the best option was to go under Xcode>Preferences>Key Bindings and in Filter type "find selected text in workspace" and bind it to your desired key, I binded it to Shift+Ctrl+Option+Cmd+F
Note: I am using Xcode version 10.3
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.
精彩评论