Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode "move line" keyboard shortcut

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

like image 304
dbernard Avatar asked Jan 15 '13 13:01

dbernard


People also ask

How do you move a line of code on a keyboard?

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.

How do I move a line in Mac?

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.

How do I move up and down code in Xcode?

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.

How do I move a line of text down?

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.


1 Answers

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 ⌥⌘]

like image 149
3 revs, 2 users 73% Avatar answered Sep 18 '22 21:09

3 revs, 2 users 73%