Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple-line cursor movements in XCode 4

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 ?

like image 476
phlebotinum Avatar asked Feb 10 '12 08:02

phlebotinum


People also ask

How to have multiple cursors in Xcode?

If you want to add multiple cursors at the same column, instead of wasting time aiming and clicking, you can use the arrow key to navigate. Hold ⌃ – Control and ⇧ - SHIFT then ↑ or ↓ to add cursors to the line above and below your current position. You can deselect a cursor by hit the arrow in the opposite direction.

How do I type multiple lines in Xcode?

First, hold Shift and Control (^) and then click where you want to select multiple lines and then start typing. One small caveat: unlike other text editors where you can click that same line to unselect the multi-line selection, Xcode doesn't support that yet.

How do I move up and down code in Xcode?

1) Moving a full line or many lines of code up or down using: ⌘ ⌥ { to move up and ⌘ ⌥ } to move down. If you have text selected, Xcode will move each line containing your selection; otherwise, it'll move the line the cursor is in.


2 Answers

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.

like image 192
Blaz Avatar answered Sep 29 '22 12:09

Blaz


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

like image 42
phlebotinum Avatar answered Sep 29 '22 13:09

phlebotinum