Xcode“移动线”键盘快捷键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14339275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:42:20  来源:igfitidea点击:

Xcode "move line" keyboard shortcut

xcodexcode4keyboard-shortcutskey-bindings

提问by dbernard

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

在 Xcode 4 中,我已经成功地添加了新的自定义键盘快捷键来移动行或复制一行:

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

/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/Downuses copy/paste, which I would like to avoid. Anyone knows how to move lines with yank, just like the Duplicate LineI found there: Xcode duplicate line

但是Move Line Up/Down使用复制/粘贴,我想避免这种情况。任何人都知道如何使用yank移动行,就像我在那里找到的Duplicate LineXcode 重复行

回答by jrturton

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

https://stackoverflow.com/a/9078952/852828复制,因为这不是链接重复项的公认答案。

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 ??]

Xcode 4 有一组新的命令,用于移动光标所在的行或使用command+ option+[]

??[或者 ??]

回答by Josh Withee

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

如何通过菜单或热键在 Xcode 中移动行:

enter image description here

在此处输入图片说明

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

如果您使用的是 Windows 键盘,则命令将转换为:

  • ??[..... Alt + Win + [
  • ??]..... Alt + Win + ]
  • ??[..... Alt + Win + [
  • ??]..... Alt + Win + ]