如何在 Xcode 上编辑多行(快捷方式)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29372146/
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
How edit multiple lines on Xcode (shortcut)
提问by Damien Romito
I'm sorry, I don't find an already asked question for this problem...
对不起,我没有找到有关此问题的已问问题...
in Xcode, what is the shortcut to edit multiples lines like the "CMD+click" of sublime text?
在Xcode中,编辑多行的快捷方式是什么,比如sublime text的“CMD+click”?
回答by Daniel
It is possible with Xcode 10+, see the wwdc2018 presentation of the functionality.
Xcode 10+ 是可能的,请参阅wwdc2018 功能介绍。
Ways to create multiple cursors:
创建多个游标的方法:
- shift+ control+ left mouse click: Will create a new cursor on every click
- shift+ control+ ↑: Will create a new cursor above
- shift+ control+ ↓: Will create a new cursor bellow
- option+ drag: Will create a new cursor on every line you drag
- shift+ control+ 鼠标左键单击:每次单击都会创建一个新光标
- shift+ control+ ↑: 将在上面创建一个新光标
- shift+ control+ ↓: 将创建一个新的光标波纹管
- option+ 拖动:将在您拖动的每一行上创建一个新光标
preview:
预览:
For more information, see this answer
有关更多信息,请参阅此答案
回答by Jace Tan
I'm not sure how helpful this is to you, but if you want to change a variable name, you can click it, hover over it until the triangle dropdown button appears, click it and select Edit All in Scope.
我不确定这对您有多大帮助,但是如果您想更改变量名称,您可以单击它,将鼠标悬停在它上面直到出现三角形下拉按钮,单击它并选择“编辑范围内的全部”。
This allows you to change all instances of that variable name.
这允许您更改该变量名称的所有实例。
回答by RoyR
Multiline editing is supported in Xcode 10, Ctrl + Shift + click the lines you want to edit.
Xcode 10 支持多行编辑,Ctrl + Shift + 单击要编辑的行。
回答by Gpx
回答by Zack
I had this same question a few weeks ago, if you use the Option Key you can use column select and edit multiple lines like in your picture. Where the confusion comes in is it is used for multiple things. If you click the option key over a variable or text it shows a question mark and shows information about what you click on. However, if you hold the option key while before the line or not over text it shows up as a plus symbol and you can drag and select multiple lines and edit them at the same time.
几周前我遇到了同样的问题,如果您使用 Option Key,您可以使用列选择并编辑图片中的多行。混淆之处在于它用于多种用途。如果您单击变量或文本上的选项键,它会显示一个问号并显示有关您单击内容的信息。但是,如果您在行前或不在文本上按住选项键,它会显示为加号,您可以拖动并选择多行并同时编辑它们。