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
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
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
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:
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist
</dict>
<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>
No need to modify Xcode. You can just use the Xcode extension Linex
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.
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