xcode 多个光标/突出显示当前突出显示的单词的下一个实例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24881824/
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
Multiple cursors / highlight next instance of currently highlighted word
提问by Matt Rowles
In Sublime Text, it's easy to select the next instance of a wordby pressing command + dand also place multiple cursors by pressing command & clicking. I know I'm not alone in saying this is an incredibly useful function in editors.
在 Sublime Text 中,可以通过按command + d轻松选择单词的下一个实例,也可以通过按command 和单击放置多个光标。我知道我并不是唯一一个说这是编辑器中非常有用的功能。
I haven't had any luck in finding any key mappings or Alcatraz plugins for this, so I was interested to see if either there is a way to do this in xcode 5 which I might have missed or if there are plans to implement this in xcode 6?
我没有为此找到任何键映射或 Alcatraz 插件,所以我很想看看是否有一种方法可以在我可能错过的 xcode 5 中做到这一点,或者是否有计划在xcode 6?
If there isn't, and any xcode developers see this, would love to see this as a feature and hear your opinions on it :)
如果没有,并且任何 xcode 开发人员都看到了这一点,希望将其视为一项功能并听取您的意见:)
采纳答案by Infinity
It is possible starting from Xcode 10 Beta 3
可以从 Xcode 10 Beta 3 开始
You can add selections for the next and previous find results using the “Find and Select Next” and “Find and Select Previous” menu commands.
Additionally, you can quickly add selections for the next and previous occurrences of the current selected text using the “Select Next Occurrence” and “Select Previous Occurrence” menu commands.
您可以使用“查找并选择下一个”和“查找并选择上一个”菜单命令为下一个和上一个查找结果添加选择。
此外,您可以使用“选择下一次出现”和“选择上一次出现”菜单命令为当前所选文本的下一次和上一次出现快速添加选择。
ALT+ ?+ Eto select next occurence of currently selected
ALT+ ?+E选择当前选择的下一次出现
ALT+ SHIFT+ ?+ Eto select previous occurence of currently selected
ALT+ SHIFT+ ?+E选择当前选择的上一次出现
ALT+ ?+ Gto find and select next
ALT+ ?+G查找并选择下一个
ALT+ SHIFT+ ?+ Gto find and select previous
ALT+ SHIFT+ ?+G查找并选择上一个
You can also use the Find
menu to find these actions. Of course, feel free to bind it to different hotkeys!
您还可以使用Find
菜单来查找这些操作。当然,可以随意将其绑定到不同的热键!
回答by Max Chuquimia
If what you're wanting to do is change the name of a variable, then when your cursor is on the variable press control+command+Eand type away. (This is "Edit All in scope")
如果您想要做的是更改一个变量的名称,那么当您的光标位于该变量上时,按control+ command+E并输入即可。(这是“在范围内编辑所有内容”)
For editing on a Project scope there is always the Editor > Refactor > Rename
menu item
对于在项目范围上进行编辑,始终有Editor > Refactor > Rename
菜单项
回答by Sohail
Highlight the word you'd like to get the next instance, then press:
突出显示您希望获得下一个实例的单词,然后按:
?+ E
?+ E
and
和
?+ G.
?+ G。
Continuing to press ?+ Gwill cycle through all instances of the word you pressed ?+ Eon.
继续按?+G将循环浏览您按?+的单词的所有实例E。
I have more xcode shortcutson my site that I sometimes reference.
我的网站上有更多xcode 快捷方式,我有时会参考这些快捷方式。
回答by Alex
You can create cursors with Shift+ Ctrl+ Mouse Clickwherever you need more cursor
您可以创建光标 Shift+ Ctrl+ Mouse Click,无论你需要更多的光标
You can either use Shift+ Ctrl+ ▼(or ▲) if you want to create a new cursor on the following line.
如果要在下一行创建新光标,可以使用 Shift+ Ctrl+ ▼(或▲)。
Option+ Mouse Dragalso works very well
Option+Mouse Drag也很好用
回答by Vaibhav
I just read on twitter that Xcode team has added multiple cursors feature for testing, but kept it hidden.To enable it use following command.
我刚刚在 twitter 上看到 Xcode 团队添加了多个游标功能用于测试,但保持隐藏状态。要启用它,请使用以下命令。
defaults write com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool true
默认写入 com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool true
Link for your reference. Multiple Cursor in Xcode
链接供您参考。 Xcode 中的多个光标
回答by Jordan Hochstetler
Apple just released Xcode 10 beta with the following feature:
Apple 刚刚发布了具有以下功能的 Xcode 10 beta:
The Xcode Source Editor now supports multi-cursor editing allowing you to quickly edit multiple ranges of code at once. You can place additional cursors with the mouse via ?+?+Click or with column select (?+Click+Drag), or with the keyboard using ?+?+Up to column select up or ?+?+Down to column select down. (12564506)
Xcode 源代码编辑器现在支持多光标编辑,允许您一次快速编辑多个范围的代码。您可以使用鼠标通过 ?+?+Click 或使用列选择 (?+Click+Drag) 放置其他光标,或者使用键盘使用 ?+?+Up to column select up 或 ?+?+Down to column select down . (12564506)
回答by Daniel Schlaug
There's the Xcode-Multi-Edit-Plugin. It's still not quite like Sublime because the multiple cursors can't be used to edit beyond the selection you made when you started command-d-ing but it's close enough.
有Xcode-Multi-Edit-Plugin。它仍然不太像 Sublime,因为在您启动 command-d-ing 时无法使用多个光标进行编辑,但它已经足够接近了。
The plugin is not updated for Xcode 7.3but this can be easily fixed by adding
该插件未针对 Xcode 7.3 更新,但这可以通过添加轻松修复
<string>ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C</string>
to the list of similar UUIDs in <key>DVTPlugInCompatibilityUUIDs</key>
in the plugin's Info.plist. (Found at ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/XcodeMultiEdit.xcplugin/Contents/Info.plist
)
到<key>DVTPlugInCompatibilityUUIDs</key>
插件的 Info.plist中类似 UUID 的列表。(发现于~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/XcodeMultiEdit.xcplugin/Contents/Info.plist
)
Another promising plug-in which currently lacks Xcode 7.3 support is Multiplex.
另一个目前缺乏 Xcode 7.3 支持的有前途的插件是 Multiplex。