先說明符號對應關係,這也是最多人卡住的地方:⌘ 是 Command,⌥ 是 Option,⌃ 是 Control,⇧ 是 Shift。鍵盤上找不到某些符號,是因為菜單裡用的是符號而非字母。
另外兩個小技巧:調整圖片尺寸時按住 Option 鍵可等比縮放;讓控件與內容同大小用 Command + =。
Command + R:執行(Run)Command + .:停止F6:單步執行(Step Over)F7:跳入(Step Into)F8:繼續(Resume)這組操作邏輯與 Eclipse、Visual Studio 相當接近,有 those IDE 經驗的人可以很快上手。
Command + Control + ↑ / ↓:在 .h 與 .m 檔之間切換,非常實用Control + Command + ←:Go Back,回到上一個開啟的檔案Control + Command + →:Go Forward,回到下一個開啟的檔案Command + Shift + D:快速開啟檔案Command + 0:顯示/隱藏左側導航欄Command + Shift + N:新建專案Command + N:新建檔案Command + Control + N:新建空白檔案Command + O:開啟Command + Option + O:在新視窗開啟Command + W:關閉視窗;Command + Option + W 關閉所有視窗Command + Shift + W:關閉目前檔案;Command + Control + W 關閉目前專案Command + S:儲存;Command + Option + S 儲存全部Command + Shift + S:另存新檔;Command + Option + Shift + S 另存為副本Command + U:還原到上次儲存狀態Command + Control + S:建立快照,之後可用來比對修改Command + I:Get Info;Command + Option + I 顯示檢查器Command + P:列印縮排
Command + [:向左縮排Command + ]:向右縮排Emacs 風格游標移動(Xcode 沿用了這套綁定,熟練後很省時間)
Control + F:向右一個字元(forward)Control + B:向左一個字元(backward)Control + P:上一行(previous)Control + N:下一行(next)Control + A:移到行首Control + E:移到行尾(end)Control + T:調換游標兩側字元(transpose)Control + D:刪除游標右側字元(delete)Control + K:刪除本行游標之後的所有內容(kill)搜尋
Command + F:搜尋;Command + G 下一處;Command + Shift + G 上一處Command + Shift + F:在專案範圍內搜尋Command + Control + F:搜尋並取代Command + E:以選取字串為搜尋條件;Command + Control + E 為取代條件其他編輯
Command + Z:復原;Command + Shift + Z:重做Command + X / C / V:剪下、複製、貼上Command + Option + Shift + V:貼上並套用格式Command + A:全選Command + Shift + J:選取方法名後重構Command + /:加上或移除註解Command + D:加入書籤Command + L:跳到指定行號Option + Delete:刪除前一個單字Control + Delete:刪除本行游標前的所有內容Command + Option + 滑鼠拖曳:跨行選取程式碼折疊
Command + Control + ← / →:折疊/展開Command + Control + ↑ / ↓:折疊/展開方法Command + Control + Shift + ↑ / ↓:折疊/展開註解區塊Control + U:全部展開檔案內移動
Command + ↑ / ↓:檔案首/末行Command + ← / →:行首/行尾Option + ← / →:上一個/下一個單字Control + ← / →:上一個/下一個拆分單字Control + L:中間顯示游標位置Control + 2:方法組列表Command + Option + F:右上角詳情搜尋Command + Shift + E:縮放編輯視窗;Command + Option + Shift + E 縮放為全螢幕Command + Option + Control + F:焦點跟隨Command + 0:顯示/隱藏導航欄Command + Option + ↑:切換 header/source 檔Command + B:Build;Command + Shift + B:Build ResultsCommand + K:Compile;Command + Shift + K:CleanCommand + Shift + A:Build and AnalyzeCommand + Return:Build and Debug(開啟斷點)Command + R:Build and Run(關閉斷點)Command + Y:Build and Debug(開啟斷點)Command + =:跳到下一個警告或錯誤;Command + Shift + = 跳到上一個Command + Shift + H:隱藏問題面板Command + Option + R:Run(關閉斷點)Command + Option + Y:Debugger(開啟斷點)Command + Shift + Enter:StopCommand + Shift + R:Console;Command + Option + Control + R 清除 ConsoleCommand + \:在目前行加入斷點Command + Option + \:啟用/停用目前行斷點Command + Control + \:停用斷點Command + Option + B:顯示斷點Command + Option + P:PauseCommand + Shift + I:Step Into;Command + Option + Shift + I Step Into InstructionCommand + Shift + O:Step Over;Command + Option + Shift + O Step Over InstructionCommand + Shift + T:Step OutCommand + Option + Control + ↑ / ↓:下一個/上一個執行緒Command + Option + ← / →:返回/前進Command + Option + Shift + ← / →:上一個/下一個檔案Command + Option + Shift + ↑:在群組中定位Command + Control + B:Show Model BrowserCommand + M:最小化;Command + Option + M 全部最小化Command + H:隱藏 Xcode;Command + Option + H 隱藏其他程式Command + Q:結束 XcodeCommand + ,:偏好設定Command + Option + ?:開發文件Command + Control + ?:快速說明Command + ?:Xcode 說明Command + Option + N:新增群組;Command + Option + G 分組;Command + Option + Shift + G 復原分組Command + Option + A:加入檔案到專案Command + Shift + C:類別瀏覽Command + Shift + M:書籤Command + Option + T:特殊符號Command + Shift + ;:顯示拼字與文法檢查;Command + ; 檢查拼字Control + .:下一個填充;Option + Esc 填充列表;Control + / 下一個預留位置Command + Option + E:編輯目前 Target;Command + Option + X 編輯目前可執行檔Command + Control + O:Organizer值得注意的是,上表中有不少項目標示為「可設定」,意思是 Xcode 並未提供預設按鍵,你可以在 Key Bindings 設定中自行指派。與其硬背全部快捷鍵,不如挑幾個高頻操作先內化,例如 header/source 切換、專案內搜尋、Clean 與 Build,收益最為直接。
延伸閱讀:https://www.cocoachina.com/ios/20140731/9284.html