Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't drag (to make code snippet) in Xcode

When I follow all the instructions (including apple's video) to drag text to create a code snippet in xcode, I get a different system behavior: all I see is the selection ibeam... I can't drag. It just ends up selecting text again. Am i missing some obvious Apple-ism? Thanks

like image 446
Jack Bellis Avatar asked Jun 01 '11 19:06

Jack Bellis


People also ask

How do I create a snippet in Xcode?

The only way to create a snippet in the current version of Xcode (11.3) is: Highlight the code you want to make a snippet. Right-click, then select Create Code Snippet or select Editor Menu > Create Code Snippet.

How do I add a code snippet in Xcode 12?

Creating a code snippet is easy. Just select the code that you want to make a snippet and drag it to the code snippet section towards the bottom right of the xcode. A window will appear and there you can rename it and add a description.

How do you make a snippet?

You can also insert a snippet when logging an activity or leaving a comment on a record using the HubSpot mobile app for Android. There are two ways to add a snippet: Type the # symbol into the text editor. Start typing the snippet shortcut, then select the snippet from the dropdown menu.

Where are Xcode snippets?

For each custom snippet that we have created, there is a file stored in the directory ~/Library/Developer/Xcode /UserData/CodeSnippets/ . Those files are plain plist documents using a random UUID as a name and having the . codesnippet file extension.


1 Answers

Yes, I ran into the same problem, and Apple-ism seems to be a good term for this issue :)

It works this way:

  • Select (or highlight) the code your want to turn into a snippet
  • EDIT: Click and hold (do not drag!) on any part of the selected text for a short moment (like 2 seconds, sometimes 8 seconds)
  • EDIT: The mouse cursor will change icon (not on El Capitan).
  • Now you can drag the code over the snippets library, where a green + icon will appear. EDIT: On El Capitan the green icon does not appear, but the frame of the code snippets window will become thinner.
like image 137
brainray Avatar answered Dec 04 '22 02:12

brainray