Xcode "move line" keyboard shortcut

XcodeXcode4Keyboard ShortcutsKey Bindings

Xcode Problem Overview


In Xcode 4, I have been sucessfully able to add new custom keyboard shortcuts to move lines around or to duplicate a line:

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

<key>My Custom Keys</key>
<dict>
    <key>Move Line Up</key>
    <string>selectLine:, cut:, moveUp:, moveToBeginningOfLine:, paste:, moveUp:</string>
    <key>Move Line Down</key>
    <string>selectLine:, cut:, moveDown:, moveToBeginningOfLine:, paste:, moveUp:</string>
    <key>Duplicate Line</key>
    <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
    <key>Delete Line</key>
    <string>selectLine:, delete:</string>
</dict>

But the Move Line Up/Down uses copy/paste, which I would like to avoid. Anyone knows how to move lines with yank, just like the Duplicate Line I found there: https://stackoverflow.com/questions/10266170/xcode-4-duplicate-line/13369654#13369654

Xcode Solutions


Solution 1 - Xcode

Copied from https://stackoverflow.com/a/9078952/852828 as that isn't the accepted answer to the linked duplicate.

>Xcode 4 has a new set of command for moving the line where the cursor is or the selected text with command + option + [ or ] > >⌥⌘[ or ⌥⌘]

Solution 2 - Xcode

How to move lines in Xcode via the menu OR hotkeys:

enter image description here

If you are using a Windows keyboard, the commands would translate to:

  • ⌥⌘[ ..... Alt + Win + [
  • ⌥⌘] ..... Alt + Win + ]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondbernardView Question on Stackoverflow
Solution 1 - XcodejrturtonView Answer on Stackoverflow
Solution 2 - XcodeJosh WitheeView Answer on Stackoverflow