Column selection in Xcode
Posted by Jerry | Posted in Development | Posted on 27-05-2010-05-2008
0
Sometimes it really helps to be able to copy and paste in a column format instead of lines. Say you have a bunch of statements like this:
[[myObj1 alloc] initWithVal:10];
[[myObj2 alloc] initWithVal:20];
[[myObj3 alloc] initWithVal:30];
Now there are a lot of reasons you might want to copy those numbers, but let’s say you don’t like having the constants inline, so you want to pull them out into #define statements, like this:
#define value1 10
#define value2 20
#define value3 30
You could just retype the numbers or copy/paste the line and delete the rest of the line, but this is where column selection shines. Simply hold down the option key before starting the selection (Note: if you start dragging first, it won’t work). The cursor changes to a plus. Then select the column of numbers and cut. Before you paste them to your new lines, you will need to create the blank lines. Unlike traditional copy/paste, it will not insert the lines for you. Now add the #define and names. Finally, use column selection to copy the names and paste them back in the original lines. The paste will insert the names right in place with the original code.
