5

The same question has been asked for Xcode 3 But the solution there is said to not work with Xcode4. And no new solution is available there.

How to get a key-binding to move the curser up/down about 10 lines in Xcode 4 ?

Community
  • 1
  • 1
phlebotinum
  • 1,362
  • 1
  • 14
  • 17
  • If anybody knows for sure that there is no way then it would be great to have this as answer to be able to close this. – phlebotinum Feb 19 '12 at 15:04
  • Robo, given that today is your question's anniversary, I'd like to point out that I know (for sure) that there _is_ a way. See the answer below. ;) – Blaz Feb 10 '13 at 20:11

3 Answers3

16

Eureka! Inspired by the answer on line duplication, this is how you empower Xcode 4 with multiple-line movement:

  1. Go to the folder /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources
  2. Open IDETextKeyBindingSet.plist.
  3. Add a new dictionary Customized and two new command (say, Move Down 10 and Move Up 10) keys as the screenshot below: Editing the plist
  4. Restart Xcode and go to Preferences - Key Bindings, search for your command.
  5. Set a key combination for both commands: Key Bindings

  6. Free at last from the shackles of the Jump To shortcut. Enjoy it!


Bonus: system-wide multiple-line movement

Unleash the cursor outside Xcode following with these steps:

  1. Go to the folder ~/Library/KeyBindings
  2. Open DefaultKeyBinding.dict.
  3. Enter the following. Customize as appropriate.

    {

    "^~n" = ("moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:", "moveUp:");
    "^~p" = ("moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:", "moveDown:");

    }

  4. Logout & Login

All of the above works on 10.8.2 with Xcode 4.5.1.

Community
  • 1
  • 1
Blaz
  • 3,548
  • 5
  • 26
  • 40
  • Be careful doing this one. Somehow I managed to mess up my plist doing it this way, which caused xcode to crash on launching. I fixed it and now it works great, but if I didn't know how to go into emacs and mess with the XML I would have been in trouble. (Though I suppose if I wasn't used to emacs I wouldn't be here, now would I?) – Garrett Disco Dec 08 '14 at 20:01
  • To keep scroll position: moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp:, scrollLineUp: – Ghar Jan 24 '15 at 04:08
2

Looks like it is impossible. Answering myself to be able to close.

phlebotinum
  • 1,362
  • 1
  • 14
  • 17
1

Complementing courteous answer, I added two more commands:

Move Up 10 Extending Selection, with the value moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:

and Move Down 10 Extending Selection, with the value moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:

IDETextKeyBindingSet.plist screenshot

then assigned the shortcut in XCode:

enter image description here

Community
  • 1
  • 1
brnunes
  • 1,943
  • 26
  • 30