Xcode 缩进键绑定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6388708/
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-14 21:17:34  来源:igfitidea点击:

Xcode indentation key bindings

xcodexcode4editor

提问by Bemmu

Is there a way to get Xcode 4 to indent text so that pressing tab on selected text would indent it, shift + tab would unindent like in many editors?

有没有办法让 Xcode 4 缩进文本,以便在所选文本上按 Tab 键会缩进它,shift + Tab 会像许多编辑器一样不缩进?

The default ?]and ?[do not seem to work, probably because I have a Finnish keyboard layout. Pressing the key combination for [(alt + 8) and additionally holding down ?does not indent.

默认的?]?[似乎不起作用,可能是因为我有芬兰语键盘布局。按[(alt + 8) 的组合键并另外按住? 不缩进。

In Xcode preferences I found "Key Bindings" and "Shift Right", "Shift Left", but it does not seem to understand shift + tab. If I try to press shift + tab I get ???.

在 Xcode 首选项中,我找到了“Key Bindings”和“Shift Right”、“Shift Left”,但它似乎不理解 shift + tab。如果我尝试按 shift + tab 我得到???.

enter image description here

在此处输入图片说明

采纳答案by Thomas

Setting the Tab binding for Shift Right did not work for me either even when remapping "Insert Tab" to something else (seems hardcoded/bug). However I did get Alt + Tab and Shift + Alt + Tab binding working (with the Finnish Keyboard layout, didn't test extended or sami). I still had to remap "Insert Tab without Extra Action" from Alt + Tab to Alt + Ctrl + Tab, you could avoid this by using Ctrl instead of Alt for shifting.

即使将“插入选项卡”重新映射到其他内容(似乎是硬编码/错误),为 Shift Right 设置 Tab 绑定对我也不起作用。但是我确实得到了 Alt + Tab 和 Shift + Alt + Tab 绑定(使用芬兰语键盘布局,没有测试扩展或 sami)。我仍然必须将“无需额外操作的插入选项卡”从 Alt + Tab 重新映射到 Alt + Ctrl + Tab,您可以通过使用 Ctrl 而不是 Alt 进行移位来避免这种情况。

Here is the xml file for it.

这是它的 xml 文件。

cd ~/Library/Developer/Xcode/UserData/KeyBindings

cd ~/Library/Developer/Xcode/UserData/KeyBindings

vi Default.idekeybindings(probably empty plist, if not extend appropriately)

vi Default.idekeybindings(可能是空的 plist,如果没有适当扩展)

Paste:

粘贴:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Menu Key Bindings</key>
    <dict>
        <key>Key Bindings</key>
        <array>
            <dict>
                <key>Action</key>
                <string>shiftRight:</string>
                <key>Alternate</key>
                <string>NO</string>
                <key>CommandID</key>
                <string>Xcode.IDESourceEditor.CmdDefinition.ShiftRight</string>
                <key>Group</key>
                <string>Editor Menu for Source Code</string>
                <key>GroupID</key>
                <string>Xcode.IDESourceEditor.MenuDefinition.Editor</string>
                <key>GroupedAlternate</key>
                <string>NO</string>
                <key>Keyboard Shortcut</key>
                <string>~   </string>
                <key>Navigation</key>
                <string>NO</string>
                <key>Parent Title</key>
                <string>Structure</string>
                <key>Title</key>
                <string>Shift Right</string>
            </dict>
            <dict>
                <key>Action</key>
                <string>shiftLeft:</string>
                <key>Alternate</key>
                <string>NO</string>
                <key>CommandID</key>
                <string>Xcode.IDESourceEditor.CmdDefinition.ShiftLeft</string>
                <key>Group</key>
                <string>Editor Menu for Source Code</string>
                <key>GroupID</key>
                <string>Xcode.IDESourceEditor.MenuDefinition.Editor</string>
                <key>GroupedAlternate</key>
                <string>NO</string>
                <key>Keyboard Shortcut</key>
                <string>~$</string>
                <key>Navigation</key>
                <string>NO</string>
                <key>Parent Title</key>
                <string>Structure</string>
                <key>Title</key>
                <string>Shift Left</string>
            </dict>
        </array>
        <key>Version</key>
        <integer>3</integer>
    </dict>
    <key>Text Key Bindings</key>
    <dict>
        <key>Key Bindings</key>
        <dict>
            <key>^~ </key>
            <string>insertTabIgnoringFieldEditor:</string>
        </dict>
        <key>Version</key>
        <integer>3</integer>
    </dict>
</dict>
</plist>

回答by jtbandes

As a workaround if you can't enter shift-tab, you could find the key binding (stored at ~/Library/Developer/Xcode/UserData/KeyBindingsand modify it directly. It's XML so you should be able to do this without too much trouble.

如果您无法输入 shift-tab,作为一种解决方法,您可以找到键绑定(存储在~/Library/Developer/Xcode/UserData/KeyBindings并直接修改它。它是 XML,因此您应该能够轻松完成此操作。

回答by Tetrapike

Tabbing is included with Xcode, it's just a different key combination. The keyboard short cuts are Command-] for indent and Command-[ for un-indent.

标签包含在 Xcode 中,它只是一个不同的组合键。键盘快捷键是 Command-] 用于缩进和 Command-[ 用于取消缩进。

Another handy feature of Visual Studio that is also in Xcode is the block select feature. In Visual Studio if you hold down the Alt key while clicking and dragging you can select a block of text whose start and end columns don't have to be the beginning and end of the line.

Xcode 中的另一个方便的 Visual Studio 功能是块选择功能。在 Visual Studio 中,如果在单击和拖动时按住 Alt 键,则可以选择一个文本块,其开始和结束列不必是行的开始和结束。

You can also do this in Xcode by holding down the Option key while clicking and dragging.

您也可以在 Xcode 中通过在单击和拖动的同时按住 Option 键来执行此操作。

Found this information here: http://idevhub.com/xcode-tips-selection-indent-and-block-select/

在此处找到此信息:http: //idevhub.com/xcode-tips-selection-indent-and-block-select/