Tab Aware Xcode Comment Script

0 views
Skip to first unread message

Colin Wheeler

unread,
Feb 28, 2010, 4:19:06 PM2/28/10
to CocoaHeads DM
Nobody seems to be answering threads on Google wave right now so I thought I'd start here. I am experimenting with comment styles and wanted to try something, however I can't find an example script to get started. What I am trying to accomplish right now is this: At any tab indentation level I want to be able to invoke a Xcode script that inserts...

//========================================
// |<--- mouse cursor here

all aligned up correctly. I can easily spit out the first line, but I haven't found any example of correctly spitting out the 2nd+ line of text with the correct tab level. Whenever the 2nd line is spit out it always defaults to the first position on the line. All the example scripts I've found seem to do more with processing existing text and don't seem to deal with inserting text at correct tab levels. 

Any suggestions?

Colin Wheeler
"No fair! You changed the outcome by measuring it!" - Professor Farnsworth (Futurama)

Jim Turner

unread,
Feb 28, 2010, 5:34:31 PM2/28/10
to des-moines...@googlegroups.com
#!/usr/bin/perl
print "//========================================\n";
print "//\t";

Is that what you're looking for?

Jim

> --
> You received this message because you are subscribed to the Google Groups
> "Des Moines CocoaHeads" group.
> To post to this group, send email to des-moines...@googlegroups.com.
> To unsubscribe from this group, send email to
> des-moines-cocoa...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/des-moines-cocoaheads?hl=en.
>

Colin Wheeler

unread,
Feb 28, 2010, 5:47:17 PM2/28/10
to des-moines...@googlegroups.com
No that just does what I was talking about in my message. The 2nd line isn't aligned up with the first and looks like this

dispatch_once(&pred, ^{
if (self = [super init]) 
{
//========================================
//
delegate = nil;

The first line is aligned up correctly because xcode's already aligned it up. But the 2nd line looks like crap and isn't aligned up.

Colin Wheeler
"No fair! You changed the outcome by measuring it!" - Professor Farnsworth (Futurama)


Jim Turner

unread,
Feb 28, 2010, 10:13:42 PM2/28/10
to des-moines...@googlegroups.com
Oooh... I see the problem now. Xcode user scripts are pretty basic in
what they can accomplish. I don't think what you want to do is
possible with them. While you can add initial tabs to the start of the
second line, that doesn't seem to honor the "align comments"
preference in Xcode.

However, QuicKeys can do it. I've attached a shortcut that aligns
things properly no matter where you're at in your code. (hopefully the
attachment survives)

Jim

Comment-o-Rama.qkmx
Reply all
Reply to author
Forward
0 new messages