Xcode has a lot of built-in shortcut keys, I did not know to use before, all use the mouse instead! Later, under the guidance of an old employee of the company, I found that Xcode has many handy shortcuts!


On a Mac, you must use Command, which is the equivalent of Ctrl on a Windows computer. You need it for all kinds of shortcuts.

In Windows, Command is the Win key.

Take the time today to clean up the shortcuts in Xcode!

Shortcuts to Xcode can be viewed in Key Bindings in preferences:

A, the Xcode Menu

// 1. Open Preferences:command+, // 2. Hide Xcode:command+ H // 3. Hide Others: Option (Alt) +command+ H // 4. Disable Xcode.command + QCopy the code

Second, the File Menu

// 1. Open/add a Tab bar at the top of Xcode (this is useful when you need to switch and modify multiple pages) New Tab: comman + TCopy the code



// 2. Create/split a Window New Window: Shift +command+ H // 3. New File (call up New File window) New File:command+ N // I haven't learned how to play Swift yet, so I don't know how to play New playground... : option(alt) + Shift +command+ N // 5. New Project... : Shift +command+ N // 6. New Workspace... : Ctrl +commandNote: Folders created in this way are only in Xcode. New Group: Option (Alt) + will not be generated in the actual project file pathcommand+ N // 8. Add an existing file to the project. : option(alt) +command + ACopy the code

// 9. Open a file quickly... :command + OCopy the code

// 10. Pop up a search box to search for the file to Open (this is easier and faster than the above). : Shift +command + OCopy the code

// 11. Close Window: Shift +command+ W // 12. Close a Tab(if there is only one Tab, the current window will be closed)command+ W // 13. Close Other Windows Close Other Windows: Ctrl + Option (Alt) +command + WCopy the code

// 14. Close Document: Ctrl +command + WCopy the code

// 15. Close Workspace: Option(Alt) +command+ W // 16. Save the current file:command17. Save All files Save All: Option(Alt) +command+ S // 18. Duplicate the current file and save it as (this is not normally used)... : Shift +command+ S // 19. Save the current file As (similar to the above function) Save As... : option(alt) + Shift +command + SCopy the code

// 20. Page Setup... : Shift +command + PCopy the code

// 21. Print... :command + PCopy the code

Three, the Edit Menu

// 1. Undo (one of the most commonly used shortcuts, but also one of the most commonly used shortcuts, careful use!!) Undo :command+ Z // 2. Redo: Shift +command+ Z // 3.command+ X // 4.command+ C // 5. Copy Symbol Name: Ctrl + Shift +command+ C // 6. Copy Qualified Symbol Name: Ctrl + Option(Alt) + Shiftcommand+ C // Paste:commandPaste Special: option(Alt) +command+ V // 9. Paste and Preserve Formatting: option(Alt) + Shift +command+ V // 10. Duplicate:command+ D // 11. Select All;command+ A // 12in Navigator : option(alt) + command< span style = "box-sizing: border-box! Important; word-wrap: break-word! Importantin Library : option(alt) + commandSet font Format Show Fonts: Ctrl + Shift +command+ T // 15. Show Spelling and Grammarcommand+ : // 16. Check Document Now:command+;Copy the code

Fourth, the View Menu

// 1. Show Related Items: Ctrl + 1Copy the code

// 2. Quickly switch the left navigation areacommandAdd 1 to 8 // 3. Quickly open/close the navigation area on the leftcommand + 0Copy the code

Fifth, Find the Menu

// 1. Search for Find in the workspacein Workspace... : Shift + command+ F // 2. Find and Replace in the workspacein Workspace... : Option(alt) + Shift + command+ F // 3. :command+ F // 4. Find and Replace... : Option(alt) +command + FCopy the code

Six, Navigate to the Menu

// 1. Quickly locate the Reveal in the navigation area of the current edited file (file directory on the left)in Project Navigator : Shift + command+ J // 2. Quickly locate current navigator Revealin Debug Navigator : Shift + command+ D // 3. Open assistant editorin Assistant Editor : Option(alt) + command+, // 4. Move Focus To Editor:command+ J // 5. Quickly switch between the last page and the current open page Go Forward: Ctrl +command + ← / Ctrl + commandJump to Selection: Shift +commandJump to Definition: Ctrl +command+ J // 8. Jump to Next Issue:command + '// 9. Jump to Instruction Pointer: Ctrl + Command + PCopy the code

Seven, Navigate the Menu

// 1. Jump To the specified line. :command + LCopy the code

// 2. Toggle the.h. m file of the current class with Ctrl +command + ↑ /  Ctrl + command+ leftCopy the code

Eight, the Editor Menu

// 1. Move the code left or rightcommand+ [orcommand+] // 2. Move code up or down Option(Alt) +command + [ 或 Option(alt) + command// 3. Quick comment/uncommentcommand+ // / 4. Quickly add document comments Option(Alt) +command+ // / 5. Quickly shrink/open code block Option(Alt) +command + ← / Option(alt) + commandQuickly shrink/open all code blocks Option(Alt) + Shift +command + ← / Option(alt) + Shift + command+ -Copy the code

Nine, the Product Menu

// 1. Run:command + R / Option(alt) + command+ R // 2.command + U / Option(alt) + command + U
// 3. ProFile
Profile : command + I / Option(alt) + command + I
// 4. Analyze
Analyze : Shift + command + B / Option(alt) + Shift + command+ B // 5. Run Without Building: Ctrl +command+ R // 6.command+ B // 7. Clear Clear: Shift +commandClear the generated folders and products. Clear Build Folder: Option(Alt) + Shift +command+ K // 9.command+.Copy the code

Ten, the Debug Menu

// 1. Activate all Breakpoints:command// Add Breakpoint at Current Line:command+ \ // 3. Create Symbolic Breakpoint Create Symbolic Breakpoint... : Option(alt) +command+ \ // 4.command + KCopy the code

Other

// 1. Return to the previous cursor position Ctrl +command+ ←, Ctrl +command2. Quickly view the current class method Ctrl + 6 // 3. Open the console Shift +command+ R // 4. Delete the entire selected line with Ctrl + YCopy the code

Add techniques for deleting and copying a line to Xcode

Add and delete rows and copy row shortcuts for Xcode