Xcode duplicate/delete line

前端 未结 22 1648
不思量自难忘°
不思量自难忘° 2020-12-04 04:59

Coming from Eclipse and having been used to duplicate lines all the time, it\'s pretty strange finding out that Xcode has no such function. Or does it?

I know it\'s

相关标签:
22条回答
  • 2020-12-04 05:22

    Go to this address :

    /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet

    and then copy IDETextKeyBindingSet.plist file in some where and then open copied file and insert

    selectLine:, copy:, paste:, paste: like this picture enter image description here and save it and replace copied file in this address /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet

    then restart xcode , open xcode prefences , go to keybinding tab , search for duplicate line(customized) and define short key for it like image below

    [1]: https://i.stack.imgur.com/UTeZu.png

    0 讨论(0)
  • 2020-12-04 05:23

    XCodePlus delete line plugin, is a XCode that does this for you. It came pre installed with Alcatraz package manager...

    https://github.com/payliu/XcodePlus

    0 讨论(0)
  • 2020-12-04 05:28

    We are on Xcode 9.0 and the keybindings are still not working. Sigh.

    I found this gist very helpful so reposting it here for future reference:

    1. Open /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist
    2. Add the following XML snippet to this file just above the bottom </dict>
    3. Go to Xcode preferences -> Key Bindings -> Text tab -> Scroll till you see Duplication
    4. Click on Duplicate Current Line, add a shortcut for it, eg. Cmnd+D (resolve any duplicate bindings)
    5. Open Xcode

    <key>Duplication</key> <dict> <key>Duplicate Current Line</key> <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string> <key>Duplicate Lines</key> <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string> <key>Delete Line</key> <string>selectLine:, deleteBackward:</string> </dict>

    0 讨论(0)
  • 2020-12-04 05:28

    No need to modify Xcode. You can just use the Xcode extension Linex

    0 讨论(0)
  • 2020-12-04 05:28

    If you already have customised your Xcode key bindings, you'll have to edit the file: ~/Library/Application Support/Xcode/Key Bindings/<user>.pbxkeys. Just add the two arrays (described above) to the Root/text dictionary.

    0 讨论(0)
  • 2020-12-04 05:30

    This is possible using BetterTouchTool. CMD+D will duplicate a line. Create a new shortcut like this:

    Use the Attach Additional Action Button to append the second and third shortcut

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