Dragging a Code Snippet Tribulations/Rapture

If you had no trouble dragging and editing the colorwell code snippet, skip this. Otherwise…

  1. I was not able to drag the snippet after selecting the text and the cursor just selected different text. A net search turned up an answer for Xcode 4 which suggested just hesitating an instant before dragging. This worked. But when I released the mouse over the library (after getting visual feedback I had the right place)…

  2. No pop-up appeared. So I tried dragging multiple times (after having joyfully discovered the magical hesitation drag) believing multiple drags would somehow work the next time which of course it didn’t. Then I closed and re-opened Xcode thinking maybe that would help. Nope. Later I discovered that the end of my virgin snippet library now had multiple “My Code Snippet” copies which I couldn’t figure out how to delete yet. A net search told me to select the snippet heading in the library and press “delete.” The bad news is that this resulted in a spinning ball and a delay of 5 seconds before Xcode fatally crashed. The good news is that upon Xcode restarting, I deleted my remaining 4 snippets without further crashes. Further good news is that I discovered I can click on the snippet(s) and edit them in what appears to be the same pop-up editing window shown in the book illustration.

I just now noticed that it is explained how to delete snippets a couple pages later

I had similar problems…but I thought dragging as fast as I could was the solution–but that only worked sporadically. If I try your suggestion and hesitate, the cross hair cursor turns into a question mark, and then an empty Quick Help popup window opens, and I can’t drag. Horrible, horrible usability problem. I can’t believe there’s no menu item for creating a code snippet.

When the edit window did not open after dragging and dropping, I looked through the list of snippets until I saw my snippet at the end of the Snippet Library, and then it felt natural to try double clicking it, which opened a popup window with an Edit button. Selecting a snippet by clicking it, then hitting the delete key also seemed intuitive.

One neat feature: double click your code snippet in the Snippet library and in the popup window click the Edit button, then next to “Completion Shortcut” enter “mysetup”(you want something unique so it won’t match some pre-existing Cocoa name). Then where you want to enter the code snippet, start typing “mysetup” and then hit Tab when you see the auto-suggestion–voila the code snippet is entered there.


  1. Select text
  2. Click and hold
  3. Wait for pointer to change
  4. Drag to snippets
  5. if youDontSeeItRightAway {
    scroll to bottom of code snippets to find it