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 possible to change the system wide keybindings but that's not what I'm after.
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 possible to change the system wide keybindings but that's not what I'm after.
To delete a line: Ctrl-A to go to the beginning of the line, then Ctrl-K to delete it, and another time Ctrl-K to remove the empty line. (I do not use Xcode very often, but I'm used to that in Emacs and other text inputs with Emacs-like bindings, and it seems to work in Xcode too.)
And to duplicate a line: I don't know of many programs that have a command for that, but usually I just use Copy+Paste - in Xcode it's CUA-like: Ctrl+A to go to the beginning of the line, Shift+ā to select it, Command+C to copy and Command+*V to paste twice (once overriding the line and once appending to it).
(from a person that types and edits text all the time, so often in different programs, and occasionally gets pissed at having to distract himself with a dumb widget while making a little correction in a text input, that he just cannot avoid remembering these sequences and habits)
To Delete Line in Xcode 10.1, please follow the steps of below screenshot to add a shortcut key.
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>
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.
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.
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