Updated 15 December 2023
As we know, we all are very fond of shortcuts in our life, to reduce our energy and time. Today we will learn how to duplicate and delete lines in Xcode using shortcut keys.
Let’s check below the procedure to duplicate and delete lines in Xcode
Step 1: Open the below directory in Finder with Cmd + Shift + G
1 |
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/ |
Step 2: Open IDETextKeyBindingSet.plist
with a text editor.
Step 3: Add the below code in IDETextKeyBindingSet.plist
file:
1 2 3 4 5 6 7 8 9 |
<key>Duplication</key> <dict> <key>Duplicate Current Line</key> <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string> <key>Duplicate Lines</key> <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string> <key>Delete Line</key> <string>selectLine:, deleteBackward:</string> </dict> |
Step 4: Open Xcode and go to Xcode preferences
-> Key Bindings
-> Text tab
-> Scroll till you see Duplication
Step 5: Click on Duplicate
Current Line
, add a shortcut for it, eg. Cmd + D
(use unique key binding which is not used for any other shortcut).
In my case, I have used Option + D for Delete any line, Option+Shift+D for the duplicate current line, and Control+Option+D for duplicates of more than 1 line.
Each table in this section lists the commands in an Xcode application menu and the keyboard shortcuts associated with each command. Here’s a list of the most common shortcuts used in Xcode:
Build: ⌘ + B
Run: ⌘ + R
Test: ⌘ + U
Stop: ⌘ + .
Clean: ⌘ + ⇧ + K
Clean the build folder: ⌘ + ⇧ + ⌥ + K
Open quickly: ⇧ + ⌘ + O
Code completion: ⌃ + Space
Hope this blog helped you to understand how to create custom shortcuts in Xcode.
For more details regarding deleting and duplicating lines, check here.
You can check our blog also on the Xcode Simulator feature.
Thanks for reading 🙂
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.