Sunday, May 1, 2011

Multiple-line cursor movements in XCode

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>
From stackoverflow
  • 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.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.