iOS开发-XCode常用快捷键整理
前言:如果我们能够掌握并巧妙地使用快捷键,可以大大加快我们的工作效率,这个对经常使用快捷键的人们来说,应该很容易理解。因此我们需要做的是,针对于自己经常使用的快捷键去进行记忆。我不会推荐你们去把所有的快捷键都记住,毕竟XCode那么多的快捷键,谁会记得到那么多啊?就算把所有记住,你将要花费多少时间?
下面我将会列举我经常会使用到的快捷键,希望能对大家有所帮助,谢谢。
2020年2月27日更新
代码缩进:
Command+[ | 左缩进 |
Command+ ] | 右缩进 |
Control + I | 格式化代码 |
工具栏窗口的切换:
command + 0 | 打开或关闭左边导航 |
option + command + 0 | 打开或关闭右边属性窗口 |
command + Shift + y | 打开或关闭下方控制台 |
类文件/代码的搜索技巧:
Option + Command + J | 搜索目录文件名 |
Option + Shift+ F | 全局搜索代码 |
Shift+Command+O | 调用Open Quickly |
Control+K | 删除从插入点到行尾的所有字符 |
Command + Option+ F | 搜索当前文件代码 |
Command + Control + 左/右 | 到上/下一次编辑的位置 |
项目编译/运行:
Command + R | 编译并运行 |
Command + B | 编译 |
Command + Shift + K | 项目清理 |
快速切换/创建新的选项卡:
Command + Shift + { | 往左边切换选项卡 |
Command + Shift + } | 往右边切换选项卡 |
Command + Shift + T | 当前页面新建窗口 |
Command + T | 打开新的选项卡 |
方法的展开/合上:
command + option + 左方向键 | 合上当前方法 |
command + option + shift + 左方向键 | 合上所有方法 |
command + option + 右方向键 | 展开当前方法 |
command + option + shift + 右方向键 | 展开所有方法 |
控制断点:
command + y | 全局激活或禁用所有的断点 |
command + \ | 当前代码增加断点 |
2019年7月31日更新
最近了解了 Emacs 快捷键,它主要是用于一些不用手从键盘上移开就能在文字中移动光标的快捷键。配合在 Xcode 中使用会很方便,接下来就来学习一下吧。
Control + F | 光标前移 |
Control + B | 光标后退 |
Control + P | 光标移动到上一行 |
Control + N | 光标移动到下一行 |
Control + A | 光标移动到行首位置 |
Control + E | 光标移动到行尾位置 |
Control + T | 交换光标两边的字符 |
Control + D | 删除光标右边的字符 |
Control + H | 删除光标左边的字符 |
Control + K | 将当前行光标以后的所有字符全部删除,便于你重写行尾的代码 |
Control + L | 将光标置于窗口正中央 |
Control + V | 往后翻一页 |
Control + O | 分离光标右边所有字符,并另起一行。若光标放置在行尾,则新起一行。 |
你可能会发现,上面的只有 Control + V 往后翻一页,但却缺少了往前翻一页的存在,这是因为 Mac 只支持部分的 emacs 快捷键,我上面列得应该也差不多了。
然后我在 让你的 OSX 拥有完整的 Emacs Binding. 看到解决方法,这样往前翻一页的快捷键就成了 Option + V 了。
我把解决方案也贴一下,在终端上键入即可:
mkdir ~/Library/KeyBindings cat > ~/Library/KeyBindings/DefaultKeyBinding.dict <<EOF { /* Keybindings for emacs emulation. Compiled by Jacob Rus. * * This is a pretty good set, especially considering that many emacs bindings * such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and * perhaps a few more, are already built into the system. * * BEWARE: * This file uses the Option key as a meta key. This has the side-effect * of overriding Mac OS keybindings for the option key, which generally * make common symbols and non-english letters. */ /* Ctrl shortcuts */ "^l" = "centerSelectionInVisibleArea:"; /* C-l Recenter */ "^/" = "undo:"; /* C-/ Undo */ "^_" = "undo:"; /* C-_ Undo */ "^ " = "setMark:"; /* C-Spc Set mark */ "^\@" = "setMark:"; /* C-@ Set mark */ "^w" = "deleteToMark:"; /* C-w Delete to mark */ /* Incremental search. */ /* Uncomment these lines If Incremental Search IM is installed */ /* "^s" = "ISIM_incrementalSearch:"; /* C-s Incremental search */ /* "^r" = "ISIM_reverseIncrementalSearch:"; /* C-r Reverse incremental search */ /* "^g" = "abort:"; /* C-g Abort */ /* Meta shortcuts */ "~f" = "moveWordForward:"; /* M-f Move forward word */ "~b" = "moveWordBackward:"; /* M-b Move backward word */ "~<" = "moveToBeginningOfDocument:"; /* M-< Move to beginning of document */ "~>" = "moveToEndOfDocument:"; /* M-> Move to end of document */ "~v" = "pageUp:"; /* M-v Page Up */ "~/" = "complete:"; /* M-/ Complete */ "~c" = ( "capitalizeWord:", /* M-c Capitalize */ "moveForward:", "moveForward:"); "~u" = ( "uppercaseWord:", /* M-u Uppercase */ "moveForward:", "moveForward:"); "~l" = ( "lowercaseWord:", /* M-l Lowercase */ "moveForward:", "moveForward:"); "~d" = "deleteWordForward:"; /* M-d Delete word forward */ "^~h" = "deleteWordBackward:"; /* M-C-h Delete word backward */ "~\U007F" = "deleteWordBackward:"; /* M-Bksp Delete word backward */ "~t" = "transposeWords:"; /* M-t Transpose words */ "~\@" = ( "setMark:", /* M-@ Mark word */ "moveWordForward:", "swapWithMark"); "~h" = ( "setMark:", /* M-h Mark paragraph */ "moveToEndOfParagraph:", "swapWithMark"); /* C-x shortcuts */ "^x" = { "u" = "undo:"; /* C-x u Undo */ "k" = "performClose:"; /* C-x k Close */ "^f" = "openDocument:"; /* C-x C-f Open (find file) */ "^x" = "swapWithMark:"; /* C-x C-x Swap with mark */ "^m" = "selectToMark:"; /* C-x C-m Select to mark*/ "^s" = "saveDocument:"; /* C-x C-s Save */ "^w" = "saveDocumentAs:"; /* C-x C-w Save as */ }; } EOF
如果你装后发现有部分快捷键存在问题,可以将 ~/Library/KeyBindings/DefaultKeyBinding.dict 删掉即可还原。
博文作者:GarveyCalvin
博文出处:http://www.cnblogs.com/GarveyCalvin/
本文版权归作者和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作!
活着,就是为了改变世界!