Xcode duplicate/delete line

前端 未结 22 1649
不思量自难忘°
不思量自难忘° 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:33

    Use user scripts.

    There are scripts to move and delete lines yet. You have to define key binds for those scripts (menu Scripts -> Edit User Scripts..., under xCode 3.2).

    To duplicate line, you have to make your own script. But it's very simple ! Duplicate the "Move Line Down" script and remove the line which delete selected text :

    delete (paragraphs startLine through endLine)
    
    0 讨论(0)
  • 2020-12-04 05:35

    To Delete Line in Xcode 10.1, please follow the steps of below screenshot to add a shortcut key.

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

    OK, so I had this working for a while and then suddenly it broke. Now I have combined from different posts here and found a solution that works for XCode 6.3.1.

    1. Go to /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/ with Finder.

    2. find the folder named Resources. Right Click it, press Get Info, unlock the sharing & permissions setting (By pressing the lock) and set it to Read & Write for all.

    3. Enter the folder and find the file IDETextKeyBindingSet.plist. Right Click it, press Get Info, unlock the sharing & permissions setting (By pressing the lock) and set it to Read & Write for all.

    4. Open the file with XCode (Default)

    5. Find deletions, right click and add a new row. Name it for example Delete Line. In the value field, type: selectLine:, deleteBackward: . (This can also be done for duplicate line: selectLine:,copy:,moveToEndOfLine:,insertNewline:,paste:,deleteBackward:)

    1. Start XCode, go to preferences / keybindings and search for Delete Line. Set shortcut. Enjoy.
    0 讨论(0)
  • 2020-12-04 05:36

    Triple click to select the whole line, command-c to select and command-v twice to duplicate it. It's not an Xcode function, it's just part of the OS.

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

    For Xcode 6.1 got to Xcode > Preferences > KeyBindings > Text And there is "Delete to End of Line" and assign a key you want.

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

    Still there is no built-in way to duplicate lines, as of Xcode 9. And custom key bindings seem to have problems.

    Update: Xcode 10.0 beta 6 (10L232m) is the same.

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