A modern xcode extension adding two key shortcuts:
- Duplicate currently selected lines
- Add a newline after the current selected line
This will duplicate one or more selected lines. It places the copies of the lines after the current selection, while leaving the cursor as is.
I like to bind this to cmd+shift+d
, so that it does the inverse of my "delete line" keybinding: cmd+d
.
You might have read this and thought: "That's just what the enter key does!" However, the key difference here is that the cursor can be anywhere in the current line. In other words, it is the same as doing a cmd+right
followed by return
, except that I find it more convinient to bind this action to shift+return
.
Can be downloaded and installed from the github releases page.
- Clone this repository, open in xcode
- Under the project, signing, for both targets:
- Select a team (You may have to create a developer account - free for use locally)
- Change signing certificate to "Development"
- (For Xcode version < 12 only) Change the XCodeKit framework to "Do not Embed"
- Product > Archive
- Wait for build to complete and organizer to appear with new archive selected
- Select Distribute App
- Select Custom > Copy App
- Choose a location, such as
thisRepo/builds/
, and export - Launch and then quit that application
- Open system preferences > Privacy & Security > Extensions > Xcode Source Editor
- Enable XLineTools
- Restart Xcode
- In Xcode preferences > Key Bindings: filter by
xline
and set key shortcuts as you choose
The commands will also appear under the menu: Editor > XLineTool. If this does not show up, it means something went wrong with the extension install process. Unfortunatly, extensions are quite finicky and break sometimes for inexplicable reasons. All I can suggest is to try again.