当我选择多行代码,并希望像往常一样用TAB键缩进它们时,它只是将它们全部删除。我来自Eclipse,在那里我总是这样做。这在Xcode中是怎么做到的?我希望不是一行一行的;)


当前回答

快捷键:

CTRL + I

注意:请选择代码重新缩进并按'control'和'i'在您的mac上。

其他回答

在Xcode 9中,你终于可以使用Tab和Shift+Tab来缩进多行代码。耶!

丹麦的键盘

Unindent:⌘+←+ 8

缩进:⌘+ + 9

首先,使用命令+a选择所有代码

其次,按住ctr键,然后按i

整个选定的代码将很好地缩进。

对于代码缩进,首先选择代码行,然后按:

命令+ alt + [

命令+alt+]

如果您想将标准Xcode的⌘+[重新映射到TAB,您可以执行以下操作:

Install a program called "Karabiner". Go to Preferences ~> "Misc and Uninstall" In "Custom Setting" section click on the "Open private.xml" button Open the file and replace its content with the following code: <?xml version="1.0"?> <root> <item> <name>Tab instead of Command+[</name> <identifier>private.swap_tab_and_cmnd+[</identifier> <autogen> __KeyToKey__ KeyCode::TAB, ModifierFlag::NONE, KeyCode::BRACKET_RIGHT, ModifierFlag::COMMAND_L | ModifierFlag::NONE </autogen> </item> </root> Go to Preferences ~> "Change Key" ~> click on "Reload XML" button Put a tick in the checkbox which is called "Tab instead of Command+[" Enjoy

PS:请注意,这个设置在你的机器上是全局的,而不仅仅是在Xcode中。但是,我相信谷歌可能会帮助你找到一个解决方案,如何进一步定制它,只应用于Xcode的变化。