Xcode 9.x Line Duplication and Deletion

Confirmed, still working in Xcode 12.5.1 on macOS Big Sur 11.5.1

  1. open /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist

  2. Add the following lines into the root dictionary

    <key>Sublime Commands</key>
    <dict>
        <key>Cut Current Line</key>
        <string>selectLine:, cut:</string>
        <key>Copy Current Line</key>
        <string>selectLine:, copy:</string>
        <key>Duplicate Current Line</key>
        <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
    </dict>
  1. restart Xcode
  2. go into the Key Bindings settings and assign any shortcut you want to the new three commands. Just search for their keys.

It's a shame that in the 21st century you still have to manually add such basic shortcuts.

Caveat

The steps have to be repeated after every update of Xcode.


The above answer seems to be broken in Xcode 9.

Here is another solution that I have verified does work in Xcode 9 GM:

<key>Custom Commands</key>
<dict>
    <key>Duplicate Current Line</key>
    <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
</dict>

Tags:

Xcode8