XCode中如何一键删除当前行

When I switched from eclipse to sublime text 2, the first hotkey I moved over was cmd+d to delete a line. I use it pretty heavily.  After using Xcode for a few months it was driving me crazy that it didn't have delete line as an option under hotkeys. Thanks to stackoverflow for the solve. To add a new custom key binding, we have to edit the Key Binding plist file: (close Xcode)

sudo vi /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist

Add this text just ABOVE the close of the <dict> at the bottom of this file:

<key>Custom</key>
    <dict>
      <key>Delete Current Line In One Hit</key>
      <string>moveToEndOfLine:, deleteToBeginningOfLine:, deleteToEndOfParagraph:</string>
    </dict>

Note that:

  • This is inside the existing <dict> so there is a </dict></plist> after this
  • This associates the named action "Delete Current Line In One Hit" to the three key actions in the string. I played around with different options here to get the right combination. For instance, if you try moveToBeginningOfLine, deleteToEndOfLine instead of vice versa, then using it on empty lines will delete the line and the entire next line. Which is unpleasant Save this and open XCode
  1. Open XCode Preferences
  2. Select Key Bindings
  3. Click on All
  4. In the SEarch box type "Delete" and search for "Delete Current Line in One Hit"
  5. Add your new binding. I use cmd+d, so I had to map duplicate to something else first
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值