如何在 Xcode 中格式化代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6543026/
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 to format code in Xcode?
提问by James Raitsev
I wonder how can I format my code to align it neatly? Does it have a feature similar to Eclipse's ctrlshiftf?
我想知道如何格式化我的代码以使其整齐对齐?它是否具有类似于 Eclipse 的功能ctrlshiftf?
回答by Piotr Kochański
Select firstthe text you want to format and then press Ctrl+I.
首先选择要格式化的文本,然后按Ctrl+ I。
Use Cmd+Afirst if you wish to format all text in the selected file.
如果您希望格式化所选文件中的所有文本,请先使用Cmd+ A。
Note: this procedure only re-indents the lines, it does notdo any advanced formatting.
注意:此程序仅重新缩进行,不进行任何高级格式化。
回答by J. Costa
Key combination to format all text on open file:
用于格式化打开文件上的所有文本的组合键:
Cmd ?A+ CtrlI
Cmd ?A+ CtrlI
回答by Dair
Select the block of code that you want indented.
Right-click (or, on Mac, Ctrl-click).
Structure → Re-indent
选择要缩进的代码块。
右键单击(或者,在 Mac 上,按住 Ctrl 键单击)。
结构 → 重新缩进
回答by superlogical
I would suggest taking a look JetBrains AppCode IDE. It has a Reformat Code command. I have come from a C# background and used Visual Studio with Jetbrains Resharper plugin, so learning AppCode has been a pleasure because many of the features in Resharper also exist in AppCode!
我建议看看 JetBrains AppCode IDE。它有一个重新格式化代码命令。我来自 C# 背景,使用 Visual Studio 和 Jetbrains Resharper 插件,所以学习 AppCode 是一种乐趣,因为 Resharper 中的许多功能也存在于 AppCode 中!
Theres too many features to list here but could well be worth checking out
此处列出的功能太多,但很值得一试