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:
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.
Rhubarb's answer is correct and works but one thing, there is more simple command in plist file. Follow all instructions of Rhubarb's but
instead of
use below
This is more clear and throw away any possibility of malfunction.
I want to write this as a comment, but my "reputation" doesn't allow me to do that.
I found a temporary workaround for Xcode 9.
Open the Xcode/Content/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist and add the lines below.
It mimics the action which happens in Xcode 8 with limited support. It only can remove just one line but I'm satisfied somehow. I hope this will be fixed soon.
After restart Xcode, you can see the customed item in
Key Bindings
like below.Bind and use it!
Edit) I think below one is better than original one.
If you are a Keyboard Maestro user, just create a macro that does the following:
I assigned it to Command-D, and made it available only in Xcode.
An easy solution for XCode 5 and 6:
Install alcatraz: http://alcatraz.io/ then use it to install the "XCodePlus delete line" plugin:
Window > Package manager
There are lots of other awesome plugins as well.
I use BetterTouchTool, it's pretty cool:
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:
Delete Line