Suppose I have a long string and I copy it to the clipboard:

s = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345";

When I paste the clipboard contents into a text editor I get that string all on a single line.

But when I use


I get


How can I avoid the line splitting? I see Options and Streams and TotalWidth in the documentation but I can't make heads or tails of any of it.

(You might wonder why I'm using {s} rather than just s: That seems to be the only way I can get a CDF document to copy anything to the clipboard.)

  • 1
    $\begingroup$ CopyToClipboard[ToString@{s}] $\endgroup$
    – unlikely
    Mar 1, 2016 at 15:24
  • $\begingroup$ Or CopyToClipboard[InputForm@{s}] it depends of what do you want for quotes... $\endgroup$
    – unlikely
    Mar 1, 2016 at 15:27
  • $\begingroup$ CopyToClipboard["{" <> s <> "}"] $\endgroup$
    – unlikely
    Mar 1, 2016 at 15:29
  • $\begingroup$ @unlikely. Thank you! CopyToClipboard[ToString@{s}] does the trick. And CopyToClipboard["{" <> s <> "}"] does not produce any output to the clipboard in a CDF document. It seems (to me) that in a CDF document only lists can be copied to the clipboard. That leaves the dangling curly brackets to deal with but that's a different question and not so critical for my needs. If you write-up your first comment as an answer I'll gladly accept it. $\endgroup$
    – JimB
    Mar 1, 2016 at 15:46
  • 1
    $\begingroup$ In the 10.1.0 Front End this works: SetOptions[$FrontEndSession, {"PageWidth" -> 1000, "ExportTypesetOptions" -> {"PageWidth" -> 1000}}]. I have no idea how this relates to CDF. $\endgroup$
    – Mr.Wizard
    Mar 1, 2016 at 17:29

1 Answer 1


Converting a comment to an answer, in the 10.1.0 Front End this works:

  {"PageWidth" -> 1000, "ExportTypesetOptions" -> {"PageWidth" -> 1000}}]

I do not use CDF so I do not know how this relates.

I found that I needed to set both options shown or the copy would still wrap. The value 1000 was purely arbitrary; Infinity may suit your needs better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.