在 Xcode 4 中查找当前选定文本的键盘快捷键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5330476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Keyboard shortcut to find the currently selected text in Xcode 4
提问by OldPeculier
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.
在 Visual Studio 中——我多年来的主要工作——我可以按 Ctrl+F 立即搜索我的文本插入符所接触的标识符或字符串,或者如果我有选择,则搜索当前选定的文本。我可以按 Ctrl+Shift+F 来搜索整个项目、解决方案或其他文件集。我喜欢这个。
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.
在 Xcode 3.*——我最近几年的主要压力——我可以按 Cmd+Opt+F 立即搜索当前选定的文本和 Cmd+Opt+Shift+F(有点少,但可行),进行搜索在整个项目中。与 VS 方法相比,我不太喜欢这种方式,因为我首先必须选择一些文本,然后进行搜索,而不是 IDE 在我没有选择任何内容时自动为我选择当前标识符。但这很好。
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 onlycopies 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).
现在在 Xcode 4 中,我注意到有一个 Cmd+E 快捷方式使 Xcode“使用选择进行查找”。但它......好吧,它糟透了。它所做的一切——显然——是复制当前选择并将其粘贴到查找框中。它不显示查找框,因此如果当前未显示查找框,则 Cmd+E 没有可见效果。Cmd-E 实际上并不调用搜索——它只是复制文本。所以现在搜索标识符变成了一个三步过程:选择标识符,按 Cmd+E,按 Cmd+F(或 Cmd+Shift+F 进行项目范围搜索)。
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.
IMO,Xcode 4 的三步过程比Xcode 3 的两步过程差,这比Visual Studio 的一步过程差。
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 Peaceeach time they want to search for an identifier?
我的问题:鉴于 UI 效率的下降以及最近的国际事件,世界是否正在走下坡路,很快一切都将在一个火热的世界末日中结束,其中仅存的少数人每次想要时都将被迫重新键入War与和平搜索标识符?
回答by OldPeculier
ughoavgfhw offered the correct answer (above). Use Cmd+Eon the selected text
to begin searching with that text. Then immediately type Cmd+Shift+Fto search the whole project for all instances of the text hit enter.
uhoavgfhw 提供了正确答案(上图)。在 上使用Cmd+开始搜索该文本。然后立即键入+ +搜索整个项目文本命中的所有实例。Eselected text
CmdShiftFenter
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.
这是非常快速、一致且明智的。它不像 Visual Studio 的单笔式 Find/Find-in-Files 那样直接——Xcode 需要两次笔画而不是一次——但就个人而言,额外的步骤并没有打扰我。
回答by guenis
Late to party but someone might benefit:
聚会迟到但有人可能会受益:
I use the free BetterTouchTooland 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.
我使用免费的BetterTouchTool并为丢失或尴尬的 Xcode 快捷方式定义了一个自定义快捷方式。您可以将多个操作附加到您的自定义快捷方式,我已将 Cmd+E - Cmd+Shift+F - Enter 分配给鼠标中键,它让我只需单击一下即可在工作区中搜索选定的文本。您可以将相同的操作分配给键盘快捷键,尽管我更喜欢使用鼠标按钮来完成此任务,因为我也使用鼠标进行文本选择。
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.
ps:BTT 为您提供了选择您的快捷方式将应用到哪个应用程序的选项,或者您可以将自定义快捷方式设为全局,我也觉得这很方便。
回答by Patrik Jurgelj
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
对我来说,最好的选择是在 Xcode>Preferences>Key Bindings 下,在过滤器类型“在工作区中找到选定的文本”并将其绑定到您想要的键,我将它绑定到 Shift+Ctrl+Option+Cmd+F
Note: I am using Xcode version 10.3
注意:我使用的是 Xcode 10.3 版