Xcode 9.x Line Duplication and Deletion

前端 未结 3 1531
北荒
北荒 2021-01-31 00:23

Up until Xcode 8.0, it was possible to customize IDETextKeyBindingSet.plist file. However, now it seems like modifying this file causes Xcode to stop behaving normally (e.g. arr

相关标签:
3条回答
  • 2021-01-31 00:52

    Confirmed, still working in Xcode 11.2.1 on macOS Catalina 10.15.4

    1. open /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist

    2. Add the following lines into the root dictionary

        <key>Sublime Commands</key>
        <dict>
            <key>Cut Current Line</key>
            <string>selectLine:, cut:</string>
            <key>Copy Current Line</key>
            <string>selectLine:, copy:</string>
            <key>Duplicate Current Line</key>
            <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
        </dict>
    
    1. restart Xcode
    2. go into the Key Bindings settings and assign any shortcut you want to the new three commands. Just search for their keys.

    It's a shame that in the 21st century you still have to manually add such basic shortcuts.

    Caveat

    The steps have to be repeated after every update of Xcode.

    0 讨论(0)
  • 2021-01-31 00:53

    The previous answer left erroneous whitespace when I tried it. This works for me in Xcode 9:

    selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:
    
    0 讨论(0)
  • 2021-01-31 01:16

    The above answer seems to be broken in Xcode 9.

    Here is another solution that I have verified does work in Xcode 9 GM:

    <key>Custom Commands</key>
    <dict>
        <key>Duplicate Current Line</key>
        <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
    </dict>
    
    0 讨论(0)
提交回复
热议问题