26

I posted a question with an HTML/CSS code snippet. The answer also provides code snippets, but they're not working 100%. Some are close though, so I'd like to mess with them, the same as when I wrote them in my question, or when someone posts a jsfiddle link. Is there any way to do that without (a) editing the question or (b) copying their snippet into a new answer?

I'd like to use the snippet editor, without any immediate intention of posting the updated snippet back to the person's answer. If that's not possible, then I'd like to request that as a feature.

I could see this being useful in the following cases:

  • Understanding a solution by experimenting with it (turning parts on/off, etc.)
  • Aiding discussion with the poster (to see the effects of certain modifications before suggesting them or asking about them)
  • Attempting to trim out pieces that you may not need when you apply the solution to your own code
7
  • 1
    @TinyGiant I added a few cases to the question
    – Dov
    Oct 7, 2015 at 17:37
  • @TinyGiant (and @rene) I guess either of those options work, but leave the door open to accidentally saving something you didn't set out to (imagine if you leave your desk for a while and come back to it)
    – Dov
    Oct 7, 2015 at 17:44
  • @rene: See meta.stackoverflow.com/questions/306455/… tl;dr the answer field is not suited to fiddling with other snippets, at all (or for any other purpose than posting answers for that matter).
    – BoltClock
    Oct 8, 2015 at 4:35
  • @Tiny Giant: "Saving" in this case doesn't mean saving the code in order to compile and run it, it means persisting it for long after what is meant to be a temporary fiddling session. Also see my response above.
    – BoltClock
    Oct 8, 2015 at 4:37
  • Should I close this as a dupe of that question, or should I close that as a dupe of this one because this explains the problem better?
    – BoltClock
    Oct 8, 2015 at 4:38
  • 1
    @BoltClock closed voted the other question as a dupe of this one ... and you might write a answer
    – rene
    Oct 8, 2015 at 6:50
  • I guess copy/pasting 20-30 lines of code into jsfiddle.net is too much work nowadays, huh? Oct 8, 2015 at 14:32

1 Answer 1

11

I recommend copying the code to JSFiddle or CodePen and messing with it there. Stack Snippets are great for providing functional code within an answer that can be seen as a working demo, but they're not really meant for just messing with code.

It'd be nice if there was a set of "migrate to [service]" buttons, but then you'd have to have a partnership between SO and the services in question, which brings up all sorts of legal issues.

5
  • 6
    Quite user script-able, in the meantime.
    – Paul Roub
    Oct 8, 2015 at 15:01
  • 1
    @PaulRoub, don't forget to add attribution.
    – zzzzBov
    Oct 8, 2015 at 15:04
  • Good point. Added a JS comment with the source URL.
    – Paul Roub
    Oct 8, 2015 at 15:07
  • @PaulRoub, i'm not familiar with CodePen's api, but if there's a way to pre-fill the pen's description, I'd recommend using that.
    – zzzzBov
    Oct 8, 2015 at 15:08
  • 2
    Done. pre-filled title with "Snippet from (page title)", and description with the source URL. Note that neither is visible until the Pen is saved, but neither is needed until then.
    – Paul Roub
    Oct 8, 2015 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .