如何在Xcode 4.6中定义自定义键盘绑定?

时间:2013-02-02 18:36:51

标签: xcode keyboard-shortcuts xcode4.6

我已经在Xcode 4.5中定义/定制了一些键盘绑定,以便为我提供更好的打字体验。

只有selectWord:的快捷方式最初是由Xcode定义的,其他的是由我添加的。它们在Xcode 4.5中运行良好。但是在我将Xcode更新为4.6之后,除了由Xcode定义的selectedWord之外,它们不再起作用。

密钥绑定文件位于 /Users/jason/Library/Developer/Xcode/UserData/KeyBindings/Default.idekeybindings

<key>Text Key Bindings</key>
    <dict>
        <key>Key Bindings</key>
        <dict>
            <key>@
</key>
            <array>
                <string>moveToEndOfLine:</string>
                <string>insertNewline:</string>
            </array>
            <key>^$D</key>
            <array>
                <string>selectLine:</string>
                <string>copy:</string>
                <string>moveToEndOfLine:</string>
                <string>insertNewline:</string>
                <string>paste:</string>
                <string>deleteBackward:</string>
            </array>
            <key>^$K</key>
            <array>
                <string>deleteToBeginningOfLine:</string>
                <string>moveToEndOfLine:</string>
                <string>deleteToBeginningOfLine:</string>
                <string>deleteBackward:</string>
                <string>moveDown:</string>
                <string>moveToBeginningOfLine:</string>
            </array>
            <key>~w</key>
            <string>selectWord:</string>
        </dict>

1 个答案:

答案 0 :(得分:2)

似乎当Xcode更新时,我们自己定义的快捷功能将被新版Xcode定义的默认快捷功能覆盖。 简而言之,我们自己定义的快捷功能将会消失,我们需要再次这样做

1.我将以下代码添加回/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist以再次定义快捷方式功能。

  <key>Customerized</key>
  <dict>
    <key>Insert new line in middle</key>
    <string>moveToEndOfLine:, insertNewline:</string>
    <key>Duplicate Current Line</key>
    <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
    <key>Delete Current Line</key>
    <string>deleteToBeginningOfLine:, moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToBeginningOfLine:</string>
  </dict>

2.转到Xcode中的键绑定设置,然后为它们键入新的快捷键。 enter image description here