I'd like to map a key to move the cursor in the XCode up by ten lines. Of course, I want another one to move down too. The key mapping would ideally be something like 'Control-Alt-P'.
Is there a way to achieve this in XCode without resorting to Automator?
Ashley has the answer below, the formatting was a little different as the property list is in XML format.
In summary, added an entry in the following format to the 'text' section of *.pbxkeys in ~/Library/Application Support/Xcode/Key Bindings/:
<key>^~p</key>
<array>
<string>moveUp:</string>
<string>moveUp:</string>
</array>
You can use the example given here and use a DefaultKeyBinding.dict
file, except use moveUp:
and moveDown:
as your selectors.
Your particular dictionary entry would look something like this:
{
"^~P" = (
"moveUp:",
"moveUp:",
"moveUp:",
... however many times ...
"moveUp:",
);
}
I have since learned that if you have customized your keybindings through Xcode already you should instead add the same dictionary entry to your .pbxkeys
file under the text
dictionary section.
Just a reminder for the impatient who didn't read all the way to the end of oldbeamer's question and are also looking to use .pbxkeys instead of .dict:
If you are wanting to add multi-action keybindings to your pbxkeys file, the XML formatting goes like this:
<key>...</key>
<array>
<string>action1:</string>
<string>action2:</string>
<string>etc:</string>
</array>
You can edit the .pbxkeys directly using a text editor to add custom multi-action keybindings this way.
来源:https://stackoverflow.com/questions/780048/multiple-line-cursor-movements-in-xcode