Setting output width for CopyToClipboard

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

s = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
CopyToClipboard[s]


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

But when I use

CopyToClipboard[{s}]


I get

{"12345678901234567890123456789012345678901234567890123456789012345678\
90123456789012345"}


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.)

• CopyToClipboard[ToString@{s}] – unlikely Mar 1 '16 at 15:24
• Or CopyToClipboard[InputForm@{s}] it depends of what do you want for quotes... – unlikely Mar 1 '16 at 15:27
• CopyToClipboard["{" <> s <> "}"] – unlikely Mar 1 '16 at 15:29
• @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. – JimB Mar 1 '16 at 15:46
• 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. – Mr.Wizard Mar 1 '16 at 17:29 1 Answer Converting a comment to an answer, in the 10.1.0 Front End this works: SetOptions[$FrontEndSession,
{"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.