Add Xcode Text Macros
File this under “I hope there’s a better way, but this is how I did it”:
- spotlight search for xctxtmacro.
- Open C.xctxtmacro (mine opened with textedit)
- go to the end and copy and paste the “c.separatorcomment” block
- massage new entry accordingly
- restart Xcode
- use new text macro
I recommend three different ways for executing your macro, I make use of all three:
- Xcode’s key bindings preference pane (recommended for frequently used macros)
- Xcode’s autocomplete. Just type the macro’s “CompletionPrefix” and it should popup.
- Gus’ Menu Accelerator. Highly recommended. Watch his video.


August 21st, 2006 at 7:56 pm
thanks! I was trying to figure out how to do this. Why don’t they document it?! Crazy!
thanks.
February 16th, 2008 at 4:57 am
I use macros alot, and not always in xcode.
I have written a global macro tool that can be used in any editor, and i also released a set of new xcode macros: http://activata.co.uk/xcodemacros/
March 24th, 2008 at 9:23 pm
You’ve probably figured it out by now, but there is a better way.There’s a free chapter from the book “Beginning Xcode” (http://www.wrox.com/WileyCDA/WroxTitle/productCd-047175479X.html) that describes the file format. Click “Download Code” then download the “Bonus Sections Disk Image”. The only problem with the document is that the folder in which the author tells you to put your xctxtmacro file no longer works with Xcode 2.5 (and presumably 3.0). The correct folder is ~/Library/Application Support/Developer/Shared/Xcode/Specifications.
March 25th, 2008 at 3:01 pm
An additional quick tip for Xcode 3.0 - Under the Scripts > Comments > Un/Comment Selection, we have a perl script that checks for the type of file you are working in and comments appropriately. I am indulging in Ruby right now and this script does not allow for Ruby, which comments just like shell and Perl. So, if you choose to Edit Scripts under the script menu and go to this script, replace line 19 as follows:
Instead of:
if ($fileString =~ m!^($perlCmt|$cCmt)?#!\s.?/perl|^($perlCmt|$cCmt)?#!\s.?/sh!) {
Try this:
if ($fileString =~ m!^($perlCmt|$cCmt)?#!\s.?/(perl|ruby)|^($perlCmt|$cCmt)?#!\s.?/sh!) {
(no carriage returns added and I have no idea how much of this syntax will display in my comment - sorry in advance)
It makes commenting and uncommenting my Ruby scripts much, much easier.
May 1st, 2008 at 3:31 pm
anyone - make a a text macro editor, or else I will try. after all, we’re all using xcode… start working