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: Xcode duplicate line
If you put the cursor on a line of code and use the Alt+Up Arrow keys, the line of code you've selected moves up. If you use the Alt+Down Arrow keys, the line of code selected moves down.
Press ⌥⇧↑ (macOS), or Alt+Shift+Up Arrow (Windows/Linux), to move a line up. To move a line down use ⌥⇧↓ (macOS), or Alt+Shift+Down Arrow (Windows/Linux). This shortcut does not factor in scope.
1) Moving a full line or many lines of code up or down using: ⌘ ⌥ { to move up and ⌘ ⌥ } to move down. If you have text selected, Xcode will move each line containing your selection; otherwise, it'll move the line the cursor is in.
On all versions of Microsoft Excel for the PC and Windows, the keyboard shortcut Alt + Enter moves to the next line. To use this keyboard shortcut, type text in the cell and when ready for a new line, press and hold down the Alt key, then press the Enter key. The shortcut key can be used as many times as needed.
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⌥⌘]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With