Skip to content

Instantly share code, notes, and snippets.

@16892434
Forked from atereshkov/xcode-duplicate-line.md
Created September 5, 2022 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 16892434/c7294e8b1430a15acf92d087074589c9 to your computer and use it in GitHub Desktop.
Save 16892434/c7294e8b1430a15acf92d087074589c9 to your computer and use it in GitHub Desktop.
Xcode 13 duplicate line shortcut (hotkey)

Xcode 13 duplicate line shortcut

  1. Run
sudo chmod 666 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources//IDETextKeyBindingSet.plist
sudo chmod 777 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
  1. Open below directory in Finder with Cmnd + Shift + G

/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/

  1. Open IDETextKeyBindingSet.plist file in text editor

  2. Append

<key>Custom</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>
  1. Restart Xcode
  2. Go to Preferences - Key Bindings, search for the command we typed (Duplicate Lines & Duplicate Current Line, Delete Line).
  3. Set desired key binding

Taken from: https://stackoverflow.com/a/34195483/5969121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment