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

后端 未结 13 1424
故里飘歌
故里飘歌 2020-12-07 10:38

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 exam

相关标签:
13条回答
  • 2020-12-07 10:55

    I found a temporary workaround for Xcode 9.

    Open the Xcode/Content/Frameworks/IDEKit.framework/Resources/IDETextK‌​eyBindingSet.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.

    <key>Customized</key>
    <dict>
        <key>Delete Line</key>
        <string>moveToBeginningOfLine:, deleteToEndOfLine:, moveDown:, deleteBackward:</string>
    </dict>
    

    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.

    <string>moveToEndOfLine:, deleteToBeginningOfLine:, deleteToEndOfParagraph:</string>
    
    0 讨论(0)
  • 2020-12-07 10:56

    I use BetterTouchTool, it's pretty cool:

    enter image description here

    0 讨论(0)
  • 2020-12-07 10:58

    seems as though it can't be done now... feel free to correct me if I am wrong... but here is my new solution...

    go to xcode preferences, then the key bindings tab. duplicate the default set, so that you wont be mad at me when the suggestion that i make breaks something that you will use.

    find 2 keys that are adjacent and not used for any commands that you use... ";","'" perhaps.(I don't use command n for new file, so I picked n,m)

    set the first key to "Move to Begging of Line" and the second key to "Delete to end of line"

    then use that sequence to delete a line...

    alternate would be set something to select line, then just use delete.

    0 讨论(0)
  • 2020-12-07 11:05

    If you are a Keyboard Maestro user, just create a macro that does the following:

    • Command Left Arrow
    • Shift Down Arrow
    • Delete

    I assigned it to Command-D, and made it available only in Xcode.

    0 讨论(0)
  • 2020-12-07 11:05

    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.

    0 讨论(0)
  • 2020-12-07 11:08

    After a lot of search here and there, I came to the following solution:

    Press and hold control key, and then press AKK.

    (Note: second K deletes the empty line).

    Actually it is a combination of two commands: Move to Beginning of Paragraph & Delete to End of Paragraph. You may also use/set other key(s) and also may use/set/change key bindings for other command(s) e.g. Move to Beginning of Line & Delete to End of Line. I used the above (default) key bindings as they suited me.

    Edit:

    To delete more than one consecutive lines, first press and hold control key, and then pressA (just to go to the beginning of the paragraph/line), then press and hold K till all the lines are deleted (this would work as the cursor remains at the beginning).

    Just to make task easy (for me), I have set commandD for Delete to End of Paragraph and home/end to go to beginning/end of the paragraph.

    0 讨论(0)
提交回复
热议问题