PDA

View Full Version : How to open 'square brackets' in XCode faster?




bengimizrahi
Jun 22, 2008, 05:21 AM
Is there a macro that opens square brackets in XCode?

For example, suppose that my cursor is at <cursor> in the following code:

[foo method]<cursor>;

And after a key shortcut I get the following code:

[[foo method]<cursor>];

Is this possible?



Catfish_Man
Jun 22, 2008, 12:40 PM
Not that I'm aware of, but that's a good idea :)

Sayer
Jun 22, 2008, 03:31 PM
There is an integrated scripting utility that lets you write complex scripts and assign them shortcut key combos in Xcode. Unfortunately I am poolside with my work DELL Craptop so I can't go through the motions.

Basically anyone good with shell scripting should be able to make or adopt an existing shell script to put an open [ at the beginning of the current line and/or selection and put a closing ] at the end of the line.

Eraserhead
Jun 22, 2008, 04:33 PM
^^ That's not exactly what you want, you want it to put it at the beginning of the current [] block...

Mac Player
Jun 22, 2008, 04:54 PM
You might want to give a look at TextMate's Objective-C bundle scripts.

bengimizrahi
Jun 22, 2008, 11:54 PM
Hmm. The scripting cabability XCode provides appears to be too heavy for such a small task. What do you think? We have to write a (say, python) script that takes the whole text file as input, right? And I guess we need two things: 1. Get the current location of the cursor, 2. Change the current location of the cursor.