I’ve been working in TextMate for Rails development for the past year now. Recently, I’ve been doing a lot of Mac OS X and iPhone development in Objective-C. Of course, this puts me into Xcode for the vast majority of my day.
The one keyboard shortcut I missed the most in Xcode from TextMate was ctrl-shift-D or “Duplicate Lines.” It turns out it’s insanely simple to add this to your Xcode environment.
- In Xcode, go to the Script menu (the stylized S to the left of Help) and select Edit User Scripts…
- Decide where you want to place your new command (I put it at the bottom of the Text menu). Click there. Then click the + menu (lower-left corner of the window) and select New Shell Script.
- Double-click where it says “Shell Script” to edit the name of your new command. Double-clicking to the right of the name allows you to assign a keystroke to the command. I used control-shift-D — same as TextMate.
- The menus should read as follows:
- Input: Selection
- Directory: Selection
- Output: Insert after Selection
- Errors: Ignore Errors
- Now click in the script area of the window and type in the following new line:
Here’s how mine ended up looking:
That’s it! Close the window and enjoy.