How do I create a Delete-Line Keyboard shortcut in

2019-01-16 03:40发布

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.

13条回答
时光不老,我们不散
2楼-- · 2019-01-16 04:27

If you don't mind having that key binding in other apps, you could try setting it in the general Cocoa key bindings. This has an explanation.

查看更多
登录 后发表回答