English 中文(简体)
Does PBKeyBinding.dict still work for setting Xcode key bindings
原标题:

New to the Mac (OS X 10.6.2), and Xcode (3.2.1), (and new here!), I ve been tinkering with the shortcuts, using the procedures described here.

I made the folders mentioned, and the file PBKeyBindings.dict:

/* ~/Library/KeyBindings/PBKeyBinding.dict */
{
"^f"      = "moveWordForward:";            /* Ctrl-f    = next word     */
"^j"      = "moveWordForward:";
}

This was just to test the water, before embarking on stuff like:

{
"^$K" = (
    "selectLine:",
    "cut:"
);
"^$D" = (
    "selectLine:",
    "copy:",
    "moveToEndOfLine:",
    "insertNewline:",
    "paste:"
);

} (copied from another post, thanks)

Now, whatever I did (restart Xcode, restart Mac), Xcode took no notice.

Have I just done something daft, or has the whole facility been removed by the Mighty Ones?

Incidentally, another user has suggested that this can be done in Xcode Preferences, but I can t see a way of mapping multiple actions onto a key.

问题回答

All is well, a spelling mistake even more vital than those kindly corrected by cdespinosa.

The file to hold the key bindings is ~/Library/KeyBindings/PBKeyBinding.dict.

The concept is discussed in the following document, located by search in the docset for pbkey:

/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html

If you want to make Command-D perform duplicate line (a la Jetbrains IDEs) do the following:

/* ~/Library/KeyBindings/PBKeyBinding.dict */
{
    "@d" = (
        "selectLine:",
        "copy:",
        "moveToEndOfLine:",
        "insertNewline:",
        "paste:",
        "deleteBackward:"
    );
}

Then, you ll need to remap the default Command-D (instructions for OS X 10.6):

  1. Open System Preferences | Keyboard | Keyboard Shortcuts
  2. Add an application shortcut by clicking the "+" button
  3. Browse to XCode.app (in /Developer/Applications)
  4. Set Menu title to "Add to Bookmarks" and type a different/unique shortcut combo (e.g., "Ctrl + Shift + D")




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签