Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bengimizrahi

macrumors newbie
Original poster
May 24, 2008
13
0
Istanbul
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?
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
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

macrumors G4
Nov 3, 2005
10,434
12,250
UK
^^ That's not exactly what you want, you want it to put it at the beginning of the current [] block...
 

bengimizrahi

macrumors newbie
Original poster
May 24, 2008
13
0
Istanbul
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.