Custom key bindings in Xcode 8

I hate that Xcode doesn’t include a duplicate line shortcut. I have to keep adding it in every time a new version of Xcode comes out and every time, I have to Google it, so I’m pasting the SO post here that worked most recently. There must be a better way, but until I figure that out, here’s what has worked for me.



And add:

<key>Custom Commands</key>
    <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:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>

Then restart Xcode and go to Preferences -> Key Bindings and assign your shortcuts.

This was taken from:

Create keyboard shortcut to toggle Document Outline in Xcode

In Xcode, open Preferences and go to the “Key Bindings” section. Type “outline” in the search filter box. Select “Show Document Outline” and double-click to the right, in the “Key” column. A text box should appear and you can type in your new shortcut. I used Cmd+9.