Is there a way to edit Xcode's built-in snippets? There is an edit button, but pressing it doesn't seem to allow changing the snippet's text.
Any insight is appreciated.
Is there a way to edit Xcode's built-in snippets? There is an edit button, but pressing it doesn't seem to allow changing the snippet's text.
Any insight is appreciated.
I wrote a script today that uses python and uncrustify to pull the snippets out of those provided by Xcode, reformat them to my liking, and dump them into a directory where I can then import them into ~/Library/Developer/Xcode/UserData/CodeSnippets. It's on github here: Xcode4Customization
You can edit system code snippets manually:
.codesnippets file is a .plist but some strings entered with CR/LF and cannot be edited by standard plist editor.
You still can't edit the built-in system snippets. You can, however, edit "user" snippets.
The simplest solution in my mind was to create copies of all the default snippets, but modify them so that they are "user" snippets and override the default versions. I wrote a little Python script to do the job. It's very simple, and after running it all of Xcode's snippets will be magically editable via the Xcode GUI. No need to go mucking around in the plist by hand:
You'll notice that it doesn't actually change any of Xcode's internal files. It just adds files, and Xcode is smart enough to use the added files instead of the original snippets. You can roll back to the originals at any time by simply deleting the user version of the snippet. You can also run the script as many times as you want without worrying about overwriting any user snippets generated by previous runs of the script.
You can edit the Xcode system snippets using a text editor and knowing the location of the system code snippets file. In Xcode 5.1.1 the location of the system code snippets file has changed once again to:
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
and you must have
root
privileges to edit the plist file in place because its owner and permissions are as follows:The plist dictionary keys are pretty self-explanatory and for the
IDECodeSnippetIdentifier
key, you can generate UUIDs yourself using for example the command:Once you've edited the file using for instance
sudo
and your editor of choice, you have to restart Xcode in order to pick up your changes.Happy hacking!
There's a great little tool called "Snippet Edit". I just tried it, and highly recommend it. Apparently it used to be a for-pay app, but the author is now giving it away for free.
http://cocoaholic.com/snippet_edit/
Either this is a bug, or it's a feature. I believe it's the latter. You can add your own snippets, but you can't edit the built-in ones. I'd just make a new snippet and customize it to how you want it.