xcodemacosxcode4xcode8keyboard-shortcuts

How do I create a Delete-Line Keyboard shortcut in Xcode 8? The Xcode 3 solutions do not work anymore


In previous versions of Xcode it was possible to create a key binding to delete the current line. There were different solutions and they are described for example here:

Xcode: Delete line hot-key

Xcode duplicate/delete line

http://bigdiver.wordpress.com/2009/09/11/configure-homeend-key-bidings-on-mac-os-x/

http://www.betadesigns.co.uk/Blog/2010/02/03/custom-xcode-shortcuts/

All solutions include modifying one of these files:

~/Library/Application Support/Xcode/Key Bindings/*.pbxkeys
~/Library/KeyBindings/DefaultKeyBinding.dict
~/Library/KeyBindings/PBKeyBinding.dict

A good resource for the existing shortcuts in Xcode 4 is http://cocoasamurai.blogspot.com/2011/03/xcode-4-keyboard-shortcuts-now.html . There are many listed regarding deletion, but none for "delete line".

BUT, these solutions do NOT work since Xcode 4.

Update: Issue is still the same as of Xcode 5.1.1

Update: Issue is still the same as of Xcode 6.1 GM Seed 2

Update: Still applies to Xcode Version 7.3 (7D175) as of 26th April 2016

Update: Six years later Xcode 8.3 has a built-in solution. See answer below.


Solution

  • Looks like Xcode 8.3 finally added the Delete Line command 🎉

    By default, no keyboard shortcut is assigned to it, so you will need to add one yourself in:

    1. Open Xcode > Preferences > Key Bindings
    2. Search for Delete Line
    3. Add a keyboard shortcut in the Key column (eg, controloptionD)

    Xcode Key Bindings