随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。

你的呢?


当前回答

可能不需要多说,但是如果你想使用字内导航,确保你改变了空格的预设键(在Expose & Spaces首选项窗格中),如果你使用它。

我切换空格使用Ctrl-Option左/右。

编辑:要将空格设置为Ctrl-Option左/右,选择“在空格之间切换:”弹出并按住Option键。第一项将从Ctrl方向键更改为Ctrl- option方向键。

其他回答

如果高亮显示搞砸了,如果你的变量没有高亮显示或其他任何东西,只需执行⌘-A⌘-X⌘-V,这将全部选中,剪切和粘贴,所有高亮显示将被纠正。所以只要按住⌘,然后按A X V。

我刚刚发现了如何改变文本宏中使用的缩进行为:

例如,如果你和我一样,不喜欢这个:

if (cond) {
  code;
}

但我更喜欢这样:

if (cond)
{
  code;
}

然后你可以通过在终端中设置以下默认值来全局(所有语言)更改此设置:

defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict-add BlockSeparator "\n"

这个问题已经困扰我很多年了,我希望其他人也会感兴趣。

这个特性的文档可以在Xcode用户默认参考中找到

Cmd+Option+O to open a file in a separate window. Can configure Tab to always indent. I frequently use it to indent an entire file. Ctrl+Arrow keys to move between camel case words. If you have OneTwo, you can move from One to Two with Ctrl+Right arrow. You can use emacs bindings, there's even kill ring! I use the Ctrl+w and Cmd+C together when I need to copy two different pieces of text. In the documentation browser, you can restrict your searches to a particular library, e.g., just iOS 4.2 library. This helps me focus on API available only on a particular iOS/Mac version of the SDK. Cmd+Shift+A to build and analyze.

alt -左&右转到行尾/开始。这与ctrl -左&右一起移动到下一个大写字母或换行字。这两个帮我省了不少时间

按左/按右键导航变量或方法名中的单词。没有这个我活不下去。